All Submissions


After placements, all the boys of CSE branch have no work to do. So, they decide to play CSE Cricket Premier League. There are N teams. For every match played, the winner gets 2 points and losing team gets 0 points. If the outcome is draw, both teams get 1 points each. Different teams may have played different number of matches.

Given the number of teams and the points obtained by each of them, find the minimum number of matches that have been played in the tournament. If the points doesn't represent a valid state, print -1.

Input Specifications
First line contains the number of test cases. Every test is consists of two lines. First line contains a single integer N. Second line contains N integers representing the points (Pi) of N teams .

Output Specifications
For every test case print the minimum number of matches that have been played in the tournament. If the points doesn't represent a valid state, print -1.

Constraints
T <= 100
N <= 100
0 <= Pi <= 100

Sample Test Cases
Input
4
3
10 1 1
3
1 1 1
6
0 0 0 0 0 0
3
13 8 7


Output
6
-1
0
14


Problem Setter : Shikhar Sharad

Languages: AWK,Bash,Brain,C,C++,Java,C#,JavaScript,Pascal,Perl,PHP,Python,Python3,Ruby,Text

Time Limit: 2 Second(s)
Score: 100 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0