#P17280. 飞向天空的约定

飞向天空的约定

Background

"Even if we do not look up at the starry sky, it is always watching us."

Problem Description

Countless jellyfish that once traveled with you have turned into tiny starlight and slowly risen into the boundless night sky. They can be represented as nn points on an infinitely long number line, where the ii-th point is initially at aia_i. Multiple points may be at the same position.

Index wants to perform at most 1021810563310^{218105633} evolutions on these points (the number of times can be 00). In one evolution, she will:

  1. Choose a position xx that currently contains at least two points.
  2. Decrease the number of points at xx by 22.
  3. Increase the number of points at x−1x-1 and x+1x+1 by 11 each.

Index wants to know the maximum possible value of the mex⁡\operatorname{mex} of the set formed by the positions of all points after the operations finish.


Note: For an integer set SS, mex⁡(S)\operatorname{mex}(S) is defined as the smallest non-negative integer that does not belong to SS.

Input Format

The first line contains an integer TT, the number of testdata groups.

For each testdata group:

The first line contains an integer nn.

The second line contains nn integers a1,a2,…,ana_1,a_2,\ldots,a_n, representing the initial positions of the points.

Output Format

For each testdata group, output one integer per line, representing the maximum mex⁡\operatorname{mex} that can be achieved.

1
4
1 1 2 2
4

Hint

One possible sequence of operations is:

{1,1,2,2}→{0,2,2,2}→{0,1,2,3}.\{1,1,2,2\}\to\{0,2,2,2\}\to\{0,1,2,3\}.

At this time, the positions of all points are {0,1,2,3}\{0,1,2,3\}, and its mex⁡\operatorname{mex} is 44. It can be proven that the answer cannot be larger.


Constraints (for all testdata):

1≤n,∑n≤5×105,0≤ai≤1091\le n,\sum n\le 5\times 10^5,0\le a_i\le 10^9。

::cute-table{tuack}

Test Point ID n,∑n≤n,\sum n\leq ai≤a_i\leq Special Property
1∼31\sim 3 8080 88 None
4∼94\sim 9 20002000 ^
10∼1310\sim 13 5×1045\times 10^4
14,1514,15 ^ 10910^9
16,1716,17 5×1055\times 10^5 ^ A
18∼2518\sim 25 ^ None

Special Property A: All aia_i are guaranteed to be the same.

Input Format

Output Format

Hint

Translated by ChatGPT 5