Codeforces Round 789 (Div. 2)
A
Tokitsukaze and All Zero Sequence
Codeforces
800
原题
←B1 →
翻译中…

Tokitsukaze has a sequence $a$ of length $n$. For each operation, she selects two numbers $a_i$ and $a_j$ ($i \ne j$; $1 \leq i,j \leq n$).

翻译中…
  • If $a_i = a_j$, change one of them to $0$.
  • Otherwise change both of them to $\min(a_i, a_j)$.
翻译中…

Tokitsukaze wants to know the minimum number of operations to change all numbers in the sequence to $0$. It can be proved that the answer always exists.

翻译中…

Input

翻译中…

The first line contains a single positive integer $t$ ($1 \leq t \leq 1000$) — the number of test cases.

翻译中…

For each test case, the first line contains a single integer $n$ ($2 \leq n \leq 100$) — the length of the sequence $a$.

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \leq a_i \leq 100$) — the sequence $a$.

翻译中…

Output

翻译中…

For each test case, print a single integer — the minimum number of operations to change all numbers in the sequence to $0$.

翻译中…

Note

翻译中…

In the first test case, one of the possible ways to change all numbers in the sequence to $0$:

翻译中…

In the $1$-st operation, $a_1 \lt a_2$, after the operation, $a_2 = a_1 = 1$. Now the sequence $a$ is $[1,1,3]$.

翻译中…

In the $2$-nd operation, $a_1 = a_2 = 1$, after the operation, $a_1 = 0$. Now the sequence $a$ is $[0,1,3]$.

翻译中…

In the $3$-rd operation, $a_1 \lt a_2$, after the operation, $a_2 = 0$. Now the sequence $a$ is $[0,0,3]$.

翻译中…

In the $4$-th operation, $a_2 \lt a_3$, after the operation, $a_3 = 0$. Now the sequence $a$ is $[0,0,0]$.

翻译中…

So the minimum number of operations is $4$.

翻译中…

样例

Input #1
3
3
1 2 3
3
1 2 2
3
1 2 0
Output #1
4
3
2
InputCopy OutputCopy
题目信息
题号
1678A
时间限制
1 s
内存限制
256 MB
标签
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。