Castle of Winterfell
Practice
3.7 (16 votes)
Very Easy
Very easy
Problem
37% Success 2097 Attempts 10 Points 1s Time Limit 256MB Memory 50 KB Max Code

Daenerys Targaryen set her eyes on The Kingdom of The North which is ruled by the House Stark. There is a huge market in the Castle of Winterfell that sells products of all prices starting from 1 coin i.e. there are products worth Rs 1, 2, 3 . . . 10^17 .

Ned Stark is the Lord of Winterfell. He gives Daenerys some coins. Each coin has its own denomination (in Rs). The coins need not be of distinct denomination. He asks Daenerys to predict the cheapest product that she will not be able to buy from the market using the coins given to her. If she can correctly predict it, she'll win the Castle of Winterfell and hence conquer one kingdom successfully.

If she can buy all products from the market (i.e all products upto price Rs 10^17 ), then output -1.

You're appointed as her advisor after she sent away Ser Jorah Mormont. So you need to solve the problem for her.

Input

The first line contains T, the number of test cases.

The first line of each test case contains an integer N denoting the number of coins Daenerys has.

The next line contains N space separated integers indicating the denominations of the coins (A_i).

Output

The only line of output should contain 1 integer denoting the price of the cheapest product that she cannot buy. If she can buy all the products, then this line contains -1.

Constraints

1 <= T <= 100

1 <= N <= 10^5

1 <= A_i <= 10^9 for i = 1, 2, .., N

Warning

Large I/O files. Use scanf/printf instead of cin/cout or else use ios::sync_with_stdio(false).

Note

Partial marks are awarded if any test case passes.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:10
4 votes
Tags:
Very-Easy
Points:10
1 votes
Tags:
Very-Easy
Points:10
1 votes
Tags:
Very-Easy
Editorial

No editorial available for this problem.