CF1688B.Patchouli's Magical Talisman

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

Patchouli's Magical Talisman

She is skilled in all kinds of magics, and is keen on inventing new one.—Perfect Memento in Strict Sense

Patchouli is making a magical talisman. She initially has nn magical tokens. Their magical power can be represented with positive integers a1,a2,,ana_1, a_2, \ldots, a_n.

Patchouli may perform the following two operations on the tokens.

  • Fusion: Patchouli chooses two tokens, removes them, and creates a new token with magical power equal to the sum of the two chosen tokens.
  • Reduction: Patchouli chooses a token with an even value of magical power xx, removes it and creates a new token with magical power equal to x2\frac{x}{2}.

Tokens are more effective when their magical powers are odd values. Please help Patchouli to find the minimum number of operations she needs to make magical powers of all tokens odd values.

Input

Each test contains multiple test cases.

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

For each test case, the first line contains one integer nn (1n21051 \leq n\leq 2\cdot 10^5) — the initial number of tokens.

The second line contains nn intergers a1,a2,,ana_1,a_2,\ldots,a_n (1ai1091 \leq a_i \leq 10^9) — the initial magical power of the nn tokens.

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5.

Output

For each test case, print a single integer — the minimum number of operations Patchouli needs to make all tokens have an odd value of magical power.

It can be shown that under such restrictions the required sequence of operations exists.

Note

Test case 1:

aa consists solely of odd numbers initially.

Test case 2:

Choose the tokens with magical power of 11 and 22 and perform Fusion. Now a=[1,3]a=[1,3], both are odd numbers.

Test case 3:

Choose the tokens with magical power of 22 and 88 and perform Fusion. Now a=[4,10]a=[4,10].

Choose the token with magical power of 1010 and perform Reduction. Now a=[4,5]a=[4,5].

Choose the tokens with magical power of 44 and 55 and perform Fusion. Now a=[9]a=[9], and 99 is an odd number.

It can be shown that you can not make all the magical powers odd numbers in less than 33 moves, so the answer is 33.

Samples

4
2
1 9
3
1 1 2
3
2 4 8
3
1049600 33792 1280
0
1
3
10

在线编程 IDE

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