Question
Make the array Equal
You are given an array A of length N. Determine if it is possible to make all the elements of A equal by performing the following operation any number of times (possibly, zero):
For example, if A = [1, 5, 3, 5, 6],
Output
- Choose two distinct indices i and j (1 ≤ i, j ≤ N, i ≠ j); and
- Update the value at index i by setting Ai to Ai + Aj
For example, if A = [1, 5, 3, 5, 6],
- Choosing i = 5 and j = 3 would result in the array [1, 5, 3, 5, 9], since we replace A5 with A5 + A3 = 9.
- Choosing i = 2 and j = 4 would instead result in the array [1, 10, 3, 5, 6].
Output
"Yes"
if it is possible to make all elements of the array equal after performing several (possibly, zero) of these operations, otherwise output "No"
(without quotes).Input
The first line of input will contain a single integer T, denoting the number of test cases.
Each test case consists of two lines of input.
- The first line of each test case contains a single integer N, denoting the length of an array.
- The second line of each test case contains N space-separated integers, denoting the initial array.
Constraints
1 ≤ T ≤ 105
1 ≤ N ≤ 2 * 105
0 ≤ Ai ≤ 109
The sum of N over all test cases won't exceed 4 * 105.
Each test case consists of two lines of input.
- The first line of each test case contains a single integer N, denoting the length of an array.
- The second line of each test case contains N space-separated integers, denoting the initial array.
Constraints
1 ≤ T ≤ 105
1 ≤ N ≤ 2 * 105
0 ≤ Ai ≤ 109
The sum of N over all test cases won't exceed 4 * 105.
Output
For each test case, output on a new line, print "Yes" if it is possible to make all elements of array equal using any number of operations, otherwise print "No" (without quotes).
Example
Sample Input
2
3
1 1 1
2
1 2
Sample Output
Yes
No
Explanation
Test case 1: All the elements of A are already equal.
Test case 2: It can be shown that no matter how many operations are performed, it's not possible to make A1 = A2.
2
3
1 1 1
2
1 2
Sample Output
Yes
No
Explanation
Test case 1: All the elements of A are already equal.
Test case 2: It can be shown that no matter how many operations are performed, it's not possible to make A1 = A2.