文理学院程序设计在线练习


Eat cheese

Time Limit: 2 Second(s)    Memory Limit: 32 MB

Total Submission(s): 51   Accepted Submission(s): 25
Problem Description

Tom came up with a terrible way to catch Jerry. He set a trap in front of Jerry's house.And there is some cheese in the trap. This cheese is a magic cheese, and if you eat one x cheese, Jerry's weight will increase by x. Then, once Jerry starts eating cheese, the trap kicks in. And it catches Jerry when he stops eating cheese. But there's a problem. The trap doesn't catch Jerry when he weighs a perfect square. Of course the clever Jerry wanted to eat cheese as much as possible. Suppose Jerry's weight started from zero. Now, is there any way you can help him eat as much cheese as possible?

Input

The first line of the date is an integer T, which is the number of the text cases.
Then T cases follow, each case contains one integers N which is the number of cheese.
The second line have n integers w which is the weight of cheese
T <= 20
1<= n <= 20
1<= w <= 1,000,000

Output

For each case, output the maximum number of cheese you can eat in a line.

Sample Input
2
2
1 1
3
1 2 2
Sample Output
1
2
Source

2019绍兴联赛