QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 512 MB مجموع النقاط: 100

#16516. Hope

الإحصائيات

There are $n$ piles of petals in front of her. The $i$-th pile contains $a_i$ petals.

You can choose several piles and take any positive integer number of petals from each chosen pile, then combine all the taken petals into a new pile. You cannot take all the petals from any pile, but you can choose $0$ piles, meaning you perform no operation. You can perform the operation at most once.

She wants the smallest positive integer that is not equal to the number of petals in any pile to be as large as possible after your operation.

You want to find the maximum possible value of this positive integer.

Input

The input contains multiple test cases.

The first line contains a positive integer $T$, representing the number of test cases.

The following lines describe each test case. For each test case:

  • The first line contains a positive integer $n$.
  • The second line contains $n$ positive integers, representing the given sequence $a$.

Output

For each test case, output a single integer on a new line, representing the maximum possible value of the smallest positive integer that is not equal to the number of petals in any pile after your operation.

Examples

Input 1

3
3
6 1 3
6
3 1 2 1 1 3
4
3 4 3 6

Output 1

5
4
5

Note 1

For the first test case, you can choose the first pile and take $2$ petals from it.

For the second test case, you can choose to perform no operation.

For the third test case, you can take $1$ petal from the first pile and $5$ petals from the fourth pile.

Constraints

For all test cases, it is guaranteed that:

  • $1 \le T \le 10$;
  • $1 \le n \le 10^5$;
  • $1 \le a_i \le 10^9$.

This problem uses bundled testing.

  • Subtask 1 (10 points): $n=1$.
  • Subtask 2 (30 points): All elements in the sequence $a$ are distinct.
  • Subtask 3 (24 points): $a_i \le 10^4$.
  • Subtask 4 (36 points): No additional constraints.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.