Rotten Ropes

No attempts yetTime limit1sMemory limit128 MB

Problem

We have nn ropes of equal length and we want to use them to lift a heavy object. Each rope has an associated tear-off weight tt: if we try to lift an object heavier than tt with that single rope, the rope tears off. However, we may fasten several ropes to the object in parallel and lift it with all of them together. When kk ropes are used to lift an object of weight ww, each of the kk ropes -- regardless of its own tear-off weight -- is assumed to carry a weight of w/kw/k. If w/k>tw/k > t for a rope whose tear-off weight is tt, that rope tears off.

For example, three ropes with tear-off weights 11, 1010, and 1515, when all three are fastened to one object, cannot lift an object heavier than 33 unless the weakest rope tears off; but the second rope alone can lift an object of weight at most 1010.

Given the tear-off weights of the nn ropes, find the weight of the heaviest object that can be lifted by fastening some subset of the ropes so that none of them tears off.

Input

The first line contains a single integer tt (1t101 \le t \le 10), the number of test cases, followed by the data for each test case. The first line of each test case contains a single integer nn (1n10001 \le n \le 1000), the number of ropes. The next line contains nn integers between 11 and 1000010000, the tear-off weights of the ropes, separated by spaces.

Output

For each test case, output on its own line a single number: the largest weight that can be lifted without tearing off any chosen rope.