题目描述
Rupsa recently started to intern under Chef. He gave her N type of ingredients of varying quantity A1, A2, ..., AN respectively to store it. But as she is lazy to arrange them she puts them all in a storage box.
Chef comes up with a new recipe and decides to prepare it. He asks Rupsa to get two units of each type ingredient for the dish. But when she went to retrieve the ingredients, she realizes that she can only pick one item at a time from the box and can know its type only after she has picked it out. The picked item is not put back in the bag.
She, being lazy, wants to know the maximum number of times she would need to pick items from the box in the worst case so that it is guaranteed that she gets at least two units of each type of ingredient. If it is impossible to pick items in such a way, print -1.
Input
The first line of the input contains an integer T denoting the number of test cases.
The first line of each test case contains a single integer N denoting the number of different type of ingredients.
The second line contains N space-separated integers A1, A2, ..., AN denoting the quantity of each ingredient.
Output
For each test case, output a single line containing an integer denoting the answer corresponding to that test case.
Constraints
1 ≤ T ≤ 10
1 ≤ N ≤ 10^5
1 ≤ Ai ≤ 10^4
Sub tasks
Example
Input:
2
2
2 2
1
6
Output:
4
2
Explanation
In Example 1, she need to pick up all items.
In Example 2, since there is only one type of ingredient, picking two items is enough.
输入格式
见题面
输出格式
见题面