Problem1467--Maximum triangle

1467: Maximum triangle

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 7  Solved: 6
[Submit] [Status] [Web Board] [Creator:]

Description

There are N rods. We are going to select 3 of these rods to make a triangle. We are going to find the triangle with the longest perimeter among the triangles that can be made. 
In this case, write a program that outputs the maximum perimeter of the triangle found.

Input

The first line contains the number of test cases T (1 <= T <= 10). 
The next line contains the number of rods N (3 <= N <= 10,000), and the next line contains the lengths of the rods N (1 <= rod length <= 5,000), which are repeated for T.

Output

For each test case, print the maximum perimeter of the triangle found, one per line. 
If a triangle cannot be formed with the given rods, print 0.

Sample Input Copy

2
5
2 10 3 5 4
4
4 5 10 20

Sample Output Copy

12
0

Source/Category