#P1875D. Jellyfish and Mex
Jellyfish and Mex
Description
You are given an array of nonnegative integers .
Let be a variable that is initialized to , Jellyfish will perform the following operation times:
- select an index () and delete from .
- add to .
Now Jellyfish wants to know the minimum possible final value of if he performs all the operations optimally.
The MEX (minimum excluded) of an array is the smallest non-negative integer that does not belong to the array. For instance:
- The MEX of is , because does not belong to the array.
- The MEX of is , because and belong to the array, but does not.
- The MEX of is because , , , and belong to the array, but does not.
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer () — the size of the array.
The second line of each test case contains integers () — the integers in the array.
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, output a single integer — the minimum value of if the operations are performed optimally.
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer () — the size of the array.
The second line of each test case contains integers () — the integers in the array.
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, output a single integer — the minimum value of if the operations are performed optimally.
Note
In the first test case, we delete elements from in the following order: . The value of will be .