CF1535B.Array Reodering

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

Array Reodering

You are given an array aa consisting of nn integers.

Let's call a pair of indices ii, jj good if 1i<jn1 \le i \lt j \le n and gcd(ai,2aj)>1\gcd(a_i, 2a_j) \gt 1 (where gcd(x,y)\gcd(x, y) is the greatest common divisor of xx and yy).

Find the maximum number of good index pairs if you can reorder the array aa in an arbitrary way.

Input

The first line contains a single integer tt (1t10001 \le t \le 1000) — the number of test cases.

The first line of the test case contains a single integer nn (2n20002 \le n \le 2000) — the number of elements in the array.

The second line of the test case contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai1051 \le a_i \le 10^5).

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

Output

For each test case, output a single integer — the maximum number of good index pairs if you can reorder the array aa in an arbitrary way.

Note

In the first example, the array elements can be rearranged as follows: [6,3,5,3][6, 3, 5, 3].

In the third example, the array elements can be rearranged as follows: [4,4,2,1,1][4, 4, 2, 1, 1].

Samples

3
4
3 6 5 3
2
1 7
5
1 4 2 4 1
4
0
9

在线编程 IDE

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