Problem: You are given an array of integers
You can apply the following operation an arbitrary number of times:
- select an index () and replace the value of the element with the value , where is the remainder of the integer dividing by .
For a single index (value ), this operation can be applied multiple times. If the operation is applied repeatedly to the same index, then the current value of is taken into account each time. For example, if then after the first operation we get , and after the second operation we get .
Check if it is possible to make all array elements equal by applying multiple (possibly zero) operations.
For example, you have an array .
- Let's apply this operation to the first element of the array. Let's replace with . We get the array .
- Then apply this operation to the second element of the array. Let's replace with . We get the array .
Thus, by applying operations, you can make all elements of an array equal.
Input Format: The first line contains one integer () — the number of test cases. What follows is a description of each test case.
The first line of each test case contains one integer () — the size of the array.
The second line of each test case contains integers () — array elements.
It is guaranteed that the sum of over all test cases does not exceed .
Output Format: For each test case print:
- YES if it is possible to make all array elements equal;
- NO otherwise.
You can print YES and NO in any case (for example, the strings yEs, yes, Yes and YES will be recognized as a positive answer) .
Note: The first test case is clarified above.
In the second test case, it is impossible to make all array elements equal.
In the third test case, you need to apply this operation once to all elements equal to .
In the fourth test case, you need to apply this operation to all elements until they become equal to .
In the fifth test case, it is impossible to make all array elements equal.
In the sixth test case, you need to apply this operation to all elements until they become equal to .