#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 points on an infinitely long number line, where the -th point is initially at . Multiple points may be at the same position.
Index wants to perform at most evolutions on these points (the number of times can be ). In one evolution, she will:
- Choose a position that currently contains at least two points.
- Decrease the number of points at by .
- Increase the number of points at and by each.
Index wants to know the maximum possible value of the of the set formed by the positions of all points after the operations finish.
Note: For an integer set , is defined as the smallest non-negative integer that does not belong to .
Input Format
The first line contains an integer , the number of testdata groups.
For each testdata group:
The first line contains an integer .
The second line contains integers , representing the initial positions of the points.
Output Format
For each testdata group, output one integer per line, representing the maximum that can be achieved.
1
4
1 1 2 2
4
Hint
One possible sequence of operations is:
At this time, the positions of all points are , and its is . It can be proven that the answer cannot be larger.

Constraints (for all testdata):
。
::cute-table{tuack}
| Test Point ID | Special Property | ||
|---|---|---|---|
| None | |||
| ^ | |||
| ^ | |||
| ^ | A | ||
| ^ | None | ||
Special Property A: All are guaranteed to be the same.
Input Format
Output Format
Hint
Translated by ChatGPT 5