CF2185C.Shifted MEX

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

Shifted MEX

You are given an array of nn integers a1,a2,,ana_1, a_2, \ldots, a_n. You are allowed to perform the following operation once.

  • Select an integer xx (which may be negative), and for each value ii (1in)(1 \leq i \leq n), set ai=ai+xa_i = a_i + x.

For example, if a=[1,3,4,2]a = [1, 3, 4, 2], and you perform the operation with x=3x = 3, aa is now equal to [4,6,7,5][4, 6, 7, 5].

Output the maximum possible value of MEX(a)\operatorname{MEX}(a)^{\text{∗}} after the operation is performed.

^{\text{∗}}MEX(a)\operatorname{MEX}(a) is defined as the smallest non-negative integer that is not present in the array. For example, MEX([1,2,0,5])\operatorname{MEX}([1, 2, 0, 5]) is 33, and MEX([1,2,4,9])\operatorname{MEX}([1, 2, 4, 9]) is 00.

Input

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

The first line of each test case contains a single integer nn (1n30001 \le n \le 3000) — the length of array aa.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (109ai109-10^9 \le a_i \le 10^9) — the array aa.

It is guaranteed that the sum of nn over all test cases does not exceed 30003000.

Output

For each test case, output the maximum possible value of MEX(a)\operatorname{MEX}(a) after the operation has been performed.

Note

For the first test case, performing the operation with x=4x = -4 makes a=[0]a = [0], and MEX([0])=1\operatorname{MEX}([0]) = 1.

For the second test case, the MEX\operatorname{MEX} is already 44, which is the highest possible, so we can perform the operation with x=0x = 0, which will not change the array.

Samples

6
1
4
5
0 1 1 2 3
2
1 1
4
4 2 3 6
5
2 4 1 0 -1
6
-1 1 2 3 5 6
1
4
1
3
4
3

在线编程 IDE

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