#P1713B. Optimal Reduction
Optimal Reduction
No submission language available for this problem.
Description
Consider an array of positive integers.
You may perform the following operation:
- select two indices and (), then
- decrease all elements by .
Let's call the minimum number of operations needed to change array into an array of zeros.
Determine if for all permutations of , is true.
An array is a permutation of an array if consists of the elements of in arbitrary order. For example, is a permutation of while is not a permutation of .
The first line contains a single integer () — the number of test cases.
The first line of each test case contains a single integer () — the length of the array .
The second line contains integers () — description of the array .
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, print "YES" (without quotes) if for all permutations of , is true, and "NO" (without quotes) otherwise.
You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response).
Input
The first line contains a single integer () — the number of test cases.
The first line of each test case contains a single integer () — the length of the array .
The second line contains integers () — description of the array .
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, print "YES" (without quotes) if for all permutations of , is true, and "NO" (without quotes) otherwise.
You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response).
Samples
Note
In the first test case, we can change all elements to in operations. It can be shown that no permutation of requires less than operations to change all elements to .
In the third test case, we need operations to change all elements to , while only needs operations.