#d11003. 货币系统

货币系统

Currency Systems

Problem Description

During the May Day holiday, little tt visits TT countries. He finds that each country has its own currency system — a set of denominations, such as China's {1,5,10,20,50,100}\{1, 5, 10, 20, 50, 100\}.

Assume little tt has an infinite supply of each denomination. When buying something of value xx, because his math is not great, he always picks the largest denomination that does not exceed the remaining amount to pay, repeating until the payment is complete.

For example, with currency system {1,3,6}\{1, 3, 6\} and item value x=10x = 10, little tt will pay using coins of denominations 6,3,16, 3, 1 in order.

We say little tt is "smart" in a country if, for items of any value, there is no other payment scheme that uses strictly fewer coins than his method. (It is guaranteed that each country has a denomination of 11, so any value can be paid.)

Given the TT currency systems, determine whether little tt is smart in each country.

Input Format

The first line contains a positive integer TT, the number of countries.

For each country:

  • The first line contains a positive integer NN, the size of the currency system.
  • The next line contains NN positive integers a1,a2,…,aNa_1, a_2, \dots, a_N, the denominations.

Output Format

For each country, output one line with a string: if little tt is smart in this country, output Yes; otherwise output No.

You may output in any case, such as YES, yEs, NO, etc.

Sample Input

3
3
1 2 5
4
1 3 8 13
4
1 3 4 10

Sample Output

Yes
Yes
No

Sample Explanation

For the third country, when buying an item of value 66, little tt's method uses {4,1,1}\{4, 1, 1\}. However, there is a payment {3,3}\{3, 3\} using fewer coins.

Constraints

For all data: 1≤T≤1001 \le T \le 100, 1≤N≤10001 \le N \le 1000, ∑N≤1000\sum N \le 1000, and 1=a1<a2<⋯<aN≤100001 = a_1 < a_2 < \dots < a_N \le 10000.