Note:
Note that the given operation will be performed only 'N'-1 times, where 'N' is the size of the given array.
The first line of the input contains an integer T denoting the number of test cases.
The first line of each test case contains the integer N, denoting the size of the sorted array.
The second line of each test case contains N space-separated integers denoting the array elements.
The only line of output of each test case should contain a single integer which denotes the minimum cost of merging the whole array.
Constraints:
1 <= T <= 50
1 <= N <= 100
1 <= ARR[i] <= 10^6
Time Limit: 1 sec
Sample Input 1:
1
3
1 3 7
Sample Output 1:
15
Explanation for Sample Input 1:
The optimal way of merging is as follows:
Merge (1, 3). The array becomes {4, 7}. Cost for this operation is 4.
Merge (4, 7). The array becomes {11}. Cost for this operation is 11.
Therefore the total cost of merging is 4 + 11 = 15.
Sample Input 2:
1
4
3 2 4 1
Sample Output 2:
20
Explanation for Sample Input 2:
The optimal way of merging is as follows:
1. Merge (3, 2), then array becomes {5, 4, 1}. Cost for this operation is 5.
2. Merge (4, 1), then array becomes {5, 5}. Cost for this operation is 5.
3. Merge (5, 5), then array becomes {10}. Cost for this operation is 10.
Therefore the total cost of merging is 5 + 5 + 10 = 20.