Problem B
The Imp
You arrive in Ye Olde Magic Shoppe with some hard-earned
gold to purchase wondrous and unique magic items. There are
A mortal, such as you, can safely carry only one magic item. You therefore aim to get the most precious one. And obtain it you would, if not for a malicious, magical creature, known as The Imp.
The Imp can cast a mischievous spell, which transforms the content of any magic box into worthless dust. Of course, he will use the spell just after you buy a box, to make you pay for the item and not get it. You are thus forced to buy another box, and then the next one…
The Imp has enough magic to cast the spell at most
Input
The first line of input contains the number of test cases
Each test case starts with a line containing the number of
items
Output
For each test case, output one line containing your gain.
Sample Input 1 | Sample Output 1 |
---|---|
1 3 1 10 5 8 1 20 12 |
7 |