CF1692B.All Distinct

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

All Distinct

Sho has an array aa consisting of nn integers. An operation consists of choosing two distinct indices ii and jj and removing aia_i and aja_j from the array.

For example, for the array [2,3,4,2,5][2, 3, 4, 2, 5], Sho can choose to remove indices 11 and 33. After this operation, the array becomes [3,2,5][3, 2, 5]. Note that after any operation, the length of the array is reduced by two.

After he made some operations, Sho has an array that has only distinct elements. In addition, he made operations such that the resulting array is the longest possible.

More formally, the array after Sho has made his operations respects these criteria:

  • No pairs such that (i<ji \lt j) and ai=aja_i = a_j exist.
  • The length of aa is maximized.

Output the length of the final array.

Input

The first line contains a single integer tt (1t1031 \leq t \leq 10^3) — the number of test cases.

The first line of each test case contains a single integer nn (1n501 \leq n \leq 50) — the length of the array.

The second line of each test case contains nn integers aia_i (1ai1041 \leq a_i \leq 10^4) — the elements of the array.

Output

For each test case, output a single integer — the length of the final array. Remember that in the final array, all elements are different, and its length is maximum.

Note

For the first test case Sho can perform operations as follows:

  1. Choose indices 11 and 55 to remove. The array becomes [2,2,2,3,3,3][2,2,3,3][2, 2, 2, 3, 3, 3] \rightarrow [2, 2, 3, 3].
  2. Choose indices 11 and 44 to remove. The array becomes [2,2,3,3][2,3][2, 2, 3, 3] \rightarrow [2, 3].

The final array has a length of 22, so the answer is 22. It can be proven that Sho cannot obtain an array with a longer length.

For the second test case Sho can perform operations as follows:

  1. Choose indices 33 and 44 to remove. The array becomes [9,1,9,9,1][9,1,1][9, 1, 9, 9, 1] \rightarrow [9, 1, 1].
  2. Choose indices 11 and 33 to remove. The array becomes [9,1,1][1][9, 1, 1] \rightarrow [1].

The final array has a length of 11, so the answer is 11. It can be proven that Sho cannot obtain an array with a longer length.

Samples

4
6
2 2 2 3 3 3
5
9 1 9 9 1
4
15 16 16 15
4
10 100 1000 10000
2
1
2
4

在线编程 IDE

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