CF1975B.378QAQ and Mocha's Array

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

378QAQ and Mocha's Array

Mocha likes arrays, so before her departure, 378QAQ gave her an array aa consisting of nn positive integers as a gift.

Mocha thinks that aa is beautiful if there exist two numbers ii and jj (1i,jn1\leq i,j\leq n, iji\neq j) such that for all kk (1kn1 \leq k \leq n), aka_k is divisible^\dagger by either aia_i or aja_j.

Determine whether aa is beautiful.

^\dagger xx is divisible by yy if there exists an integer zz such that x=yzx = y \cdot z.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t5001\leq t\leq 500). The description of the test cases follows.

The first line of each test case contains a single integer nn (3n1053\leq n\leq 10^5) — the length of the array aa.

The second line of each test case contains nn integers a1,a2,,ana_1,a_2,\ldots,a_n (1ai1091\leq a_i \leq 10^9) — the elements of the array aa.

It is guaranteed that the sum of nn over all test cases does not exceed 10510^5.

Output

For each test case, output "Yes" if array aa is beautiful, and output "No" otherwise.

You can output "Yes" and "No" in any case (for example, strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive response).

Note

In the first test case, any two numbers in the array are coprime, so the answer is "No".

In the second test case, we can pick i=2i=2 and j=1j=1. Since every number in the array is divisible by ai=1a_i = 1, the answer is "Yes".

In the third test case, we can pick i=3i=3 and j=5j=5. 22 and 44 is divisible by ai=2a_i = 2 while 33, 66 and 1212 is divisible by aj=3a_j = 3, so the answer is "Yes".

Samples

4
3
7 3 8
5
7 1 9 3 5
5
4 12 2 6 3
5
7 49 9 3 1000000000
No
Yes
Yes
No

在线编程 IDE

建议全屏模式获得最佳体验