Codeforces Round 870 (Div. 2)
A
Trust Nobody
Codeforces
1200
原题
←B →
翻译中…

There is a group of $n$ people. Some of them might be liars, who always tell lies. Other people always tell the truth. The $i$-th person says "There are at least $l_i$ liars amongst us". Determine if what people are saying is contradictory, or if it is possible. If it is possible, output the number of liars in the group. If there are multiple possible answers, output any one of them.

翻译中…

Input

翻译中…

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

翻译中…

The first line of each test case contains a single integer $n$ ($1 \leq n \leq 100$).

翻译中…

The second line of each test case contains $n$ integers $l_i$ ($0 \leq l_i \leq n$) — the number said by the $i$-th person.

翻译中…

It's guaranteed that the sum of all $n$ does not exceed $10^4$.

翻译中…

Output

翻译中…

For each test case output a single integer. If what people are saying is contradictory, output $-1$. Otherwise, output the number of liars in the group. If there are multiple possible answers, output any one of them.

翻译中…

Note

翻译中…

In the first example, the only possible answer is that the second person is a liar, so the answer is $1$ liar.

翻译中…

In the second example, it can be proven that we can't choose the liars so that all the requirements are satisfied.

翻译中…

In the third example, everybody tells the truth, so the answer is $0$ liars.

翻译中…

样例

Input #1
7
2
1 2
2
2 2
2
0 0
1
1
1
0
5
5 5 3 3 5
6
5 3 6 6 3 5
Output #1
1
-1
0
-1
0
3
4
InputCopy OutputCopy
题目信息
题号
1826A
时间限制
1 s
内存限制
256 MB
标签
暴力
贪心
模拟
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。