CF2160A.MEX Partition

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

MEX Partition

Let a partition of a multiset BB be a collection of multisets s1,s2,,sks_1, s_2,\ldots, s_k such that each element appears the same number of times in BB and across all of s1,s2,,sks_1,s_2,\ldots,s_k.

For example, some partitions of {1,2,3,3}\{1,2,3,3\} include {1,3}+{2,3},{1,2,3,3}\{1,3\}+\{2,3\}, \{1,2,3,3\}, and {2}+{1,3}+{3}\{2\}+\{1,3\}+\{3\}, but not {1,2}+{3}\{1,2\}+\{3\}.

A partition is called valid if the mex\operatorname{mex}^{\text{∗}} of all multisets in the partition is the same. The score of a valid partition is the mex\operatorname{mex} of any multiset in the partition.

You are given a multiset AA of size nn. Find the minimum score over all valid partitions of AA.

^{\text{∗}}The minimum excluded (MEX) of a collection of integers c1,c2,,ckc_1, c_2, \ldots, c_k is defined as the smallest non-negative integer xx which does not occur in the collection cc.

Input

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

The first line of each test case contains an integer nn (1n1001 \leq n \leq 100).

The second line contains nn integers A1,A2,,AnA_1, A_2, \ldots, A_n denoting the elements of AA (0Ai1000 \leq A_i \leq 100).

It is not guaranteed that the elements are given in non-decreasing order.

Output

For each test case, output the minimum score over all valid partitions.

Note

In the first test case, the minimum score of 11 can be obtained by the partition {0}+{0}+{0}\{0\}+\{0\}+\{0\}. The partition is valid because each multiset has a mex\operatorname{mex} of 11, which is consequently the score of the partition.

In the second test case, we can use {1,2}\{1,2\} as the only multiset in the partition, which has mex0\operatorname{mex} 0.

Samples

2
3
0 0 0
2
1 2
1
0

在线编程 IDE

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