CF2061A.Kevin and Arithmetic

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

Kevin and Arithmetic

To train young Kevin's arithmetic skills, his mother devised the following problem.

Given nn integers a1,a2,,ana_1, a_2, \ldots, a_n and a sum ss initialized to 00, Kevin performs the following operation for i=1,2,,ni = 1, 2, \ldots, n in order:

  • Add aia_i to ss. If the resulting ss is even, Kevin earns a point and repeatedly divides ss by 22 until it becomes odd.

Note that Kevin can earn at most one point per operation, regardless of how many divisions he does.

Since these divisions are considered more beneficial for Kevin's development, his mother wants to rearrange aa so that the number of Kevin's total points is maximized. Determine the maximum number of points.

Input

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

The first line of each test case contains a single integer nn (1n1001\leq n \leq 100) — the number of integers.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1091\leq a_i \leq 10^9).

Output

For each test case, output one integer — the maximum number of points.

Note

In the first test case, the only arrangement of aa is [1][1]. ss becomes 11. Kevin earns no points.

In the second test case, the only possible arrangement of aa is [2,1][2, 1]. ss becomes 11 and 11 successively. Kevin earns points in both operations.

In the third test case, one possible arrangement of aa is [2,4,6][2, 4, 6]. ss becomes 11, 55, and 1111 successively. Kevin earns a point in the first operation.

Samples

5
1
1
2
1 2
3
2 4 6
4
1000000000 999999999 999999998 999999997
10
3 1 4 1 5 9 2 6 5 3
0
2
1
3
8

在线编程 IDE

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