#K45907. GCD Array Equalization

    ID: 27857 Type: Default 1000ms 256MiB

GCD Array Equalization

GCD Array Equalization

You are given an array of integers. You are allowed to perform the following operation any number of times: choose two elements (a) and (b) from the array and replace one of them with (\gcd(a, b)). The task is to determine whether it is possible to make all the elements in the array equal after a sequence of such operations.

More formally, given an array (A = [a_1, a_2, \dots, a_n]), compute (g = \gcd(a_1, a_2, \dots, a_n)). If (g) appears in (A) (i.e. if (\exists, i) such that (a_i = g)), then the answer is YES; otherwise, the answer is NO.

inputFormat

The first line of input contains an integer (T) denoting the number of test cases. Each test case consists of two lines. The first line contains an integer (n), the size of the array. The second line contains (n) space-separated integers representing the array elements.

outputFormat

For each test case, output a single line containing YES if it is possible to equalize the array using the described operation, or NO otherwise.## sample

5
2
2 4
4
5 10 20 25
3
7 11 13
4
6 12 18 24
3
4 4 4
YES

YES NO YES YES

</p>