问题 G: Polygon

问题 G: Polygon

时间限制: 1 Sec  内存限制: 128 MB
提交: 12  解决: 6
[状态] [讨论版] [提交] [命题人:]
题目描述

Alex has n matches, followed by the number n represents the length of each match. The
problem is that can these matches form a polygon, and the perimeter of the polygon is the
largest.

输入

Input starts with an integer T(T <= 100), denoting the number of test cases.
Each case contains one integer N(3 <= N <= 1000) denoting the number of matches. The
next line contains N space separated integers which form the array. These integers range
in [1,10000].

输出

For each test case, If a polygon can be formed, output the largest perimeter,
otherwise output -1.

样例输入 Copy
2
3
2 3 5
4
2 2 2 7
样例输出 Copy
-1
6