Canvas Painting
Time limit1sMemory limit256 MB
Arrange the canvases in a line and repeatedly split one color group into two so every canvas ends with its own color at the smallest total repaint cost.
Problem
After last year's success, Samuel W. E. R. Craft is better known than ever, and he now has the money for every project that comes to mind. His newest one is a row of canvases painted so that no color repeats.
Samuel bought a set of white canvases of varying sizes. Painting them by hand would take far too long, so he built a large machine that does the painting for him. The machine works like this.
- Place all canvases in a line on the machine's conveyor belt, in any order you choose.
- Pick a color and a number smaller than the number of canvases that currently have color .
- Going from left to right, repaint every canvas of color . The first of them get a new color , and the rest get a new color . The machine picks and ; they differ from each other and from every color used before. The ink spent in this step equals the sum of the sizes of the repainted canvases.
- Repeat steps 2 and 3 until every canvas has a different color.
Suppose Samuel bought four canvases of sizes 3, 5, 5 and 7. The picture below shows two ways of painting them.

Given the sizes of the canvases Samuel bought, find the smallest amount of ink the machine has to spend so that every canvas ends up with a different color.
Input
The first line contains one integer , the number of test cases. Each test case takes two lines. The first line contains one integer , the number of canvases. The second line contains space separated integers, the sizes of the canvases.
Output
Print lines, one per test case: the smallest amount of ink the machine needs so that every canvas has a different color.
Constraints
- , the number of test cases.
- , the number of canvases in the -th test case.
- , the size of each canvas.
- , the number of canvases over all test cases in one input file.