You have moved to Colorland. Currency System here consists of various type of coins.
Each coin in Colorland has exactly one color. The coin color follow these rules.
All coins of same denomination have same color.
No two coins of different type have same color.
You know all coin denominations used in Colorland, but you dont know their colors. You dont even know the set of colors used for them.
For each denomination you would like to know the color of coins of that denomination. For that, you have a credit card and an ATM , both having infinite amount.
You can ask for some amount X from the ATM. The ATM will provide you with the required amount of money with those coins. It uses the following pseudocode to uniquely determine the set of coins it will use to pay you X amount of money.
func(x, a, n) // a is array containing different denominations
sort(a, n)
for i = n to 1
t = x / a[i]
give t coins of i'th type
x -= t * a[i]
You will be given long A[] which shows the different coin denominations available. A[1] will always be 1 so ATM can always give desired amount of money.
Determine if there exists some X, for which the number of coins of each denomination given by ATM is different and non-zero so that you can identify what color each denomination coins are of.
If there exists some X, print "YES" else print "NO".
Input Format:
First line contains T, the number of test cases.
For each test case, first line contains N, the number of different coin denominations.
Second line contains N distinct integers which are sorted in ascending order.
Output Format :
Print YES/NO for each test case in a single line.
Constrains :
1 <= T <= 10^6
1 <= N <= 10^6
1 <= sum of N over all cases <= 10^6
1 <= A[i] <= 10^18
For test case 1, take X = 23.
ATM will give 3 coins of 6$, 1 coin of 3$ and 2 coins of 1$
In {3 , 1 , 2}, each number is non-zero and distinct. Hence, you can identify color of each denomination.
For test case 2, there doesn't exist any valid X.
For e.g. taking X = 7,
ATM will give 1 coin of 4$, 1 coin of 2$ and 1 coin of 1$
In {1 , 1 , 1} , all elements are not distinct. Hence it is not valid.
Similarly, For X = 10,
ATM will give 2 coins of 4$, 1 coin of 2$ and 0 coins of 1$
In {2 , 1 , 0}, all elements are not non-zero. Hence it is not valid.