B. MIN = GCD
greedy; math; number theory
You are given a positive integer sequence \(a\) of length \(n\). Determine if it is possible to rearrange \(a\) such that there exists an integer \(i\) (\(1 \le i<n\)) satisfying $$$\( \min([a_1,a_2,\ldots,a_i])=\gcd([a_{i+1},a_{i+2},\ldots,a_n]). \)\(Here \)\gcd(c)\( denotes the greatest common divisor of \)c\(, which is the maximum positive integer that divides all integers in \)c$$$.
Each test contains multiple test cases. The first line contains the number of test cases \(t\) (\(1 \le t \le 10^4\)). The description of the test cases follows. The first line of each test case contains a single integer \(n\) (\(2 \le n \le 10^5\)).The second line contains \(n\) integers \(a_1, a_2, \ldots, a_n\) (\(1 \le a_i \le 10^{18}\)).It is guaranteed that the sum of \(n\) over all test cases does not exceed \(10^5\).
For each test case, output ""Yes"" if it is possible, and ""No"" otherwise.You can output the answer in any case (upper or lower). For example, the strings ""yEs"", ""yes"", ""Yes"", and ""YES"" will be recognized as positive responses.
In the first test case, rearrange \(a\) to \([1,1]\) and let \(i=1\), then \(\min([1])=\gcd([1])\).In the second test case, it can be shown that it is impossible.In the third test case, rearrange \(a\) to \([3,2,2]\) and let \(i=2\), then \(\min([3,2])=\gcd([2])\).In the fifth test case, rearrange \(a\) to \([3,4,5,6,9]\) and let \(i=3\), then \(\min([3,4,5])=\gcd([6,9])\).