CF2037A.Twice

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

Twice

Kinich wakes up to the start of a new day. He turns on his phone, checks his mailbox, and finds a mysterious present. He decides to unbox the present.

Kinich unboxes an array aa with nn integers. Initially, Kinich's score is 00. He will perform the following operation any number of times:

  • Select two indices ii and jj (1i<jn)(1 \leq i \lt j \leq n) such that neither ii nor jj has been chosen in any previous operation and ai=aja_i = a_j. Then, add 11 to his score.

Output the maximum score Kinich can achieve after performing the aforementioned operation any number of times.

Input

The first line contains an integer tt (1t5001 \leq t \leq 500) — the number of test cases.

The first line of each test case contains an integer nn (1n201 \leq n \leq 20) — the length of aa.

The following line of each test case contains nn space-separated integers a1,a2,,ana_1, a_2, \ldots, a_n (1ain1 \leq a_i \leq n).

Output

For each test case, output the maximum score achievable on a new line.

Note

In the first and third testcases, Kinich cannot perform any operations.

In the second testcase, Kinich can perform one operation with i=1i=1 and j=2j=2.

In the fourth testcase, Kinich can perform one operation with i=1i=1 and j=4j=4.

Samples

5
1
1
2
2 2
2
1 2
4
1 2 3 1
6
1 2 3 1 2 3
0
1
0
1
3

在线编程 IDE

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