 Rahul a Geek
##### Submissions: 1190   Accuracy: 48.51%   Difficulty: Easy   Marks: 2

Rahul is a geek he loves to play with array. He was very much bored so he asked you to solve array by selecting a pair of adjacent integers and remove the larger one of these two. This decreases the array size by 1. Cost of this operation will be equal to the smaller of them. Your task is to find out minimum sum of costs of operations needed to convert the array into a single element.

Input:
First line of input contains a single integer T denoting the number of test cases. First line of each test case starts with an integer N denoting the size of the array A. Next line of input contains N space separated integers, where the ith integer denotes the value Ai.

Output:
For each test case, print the minimum cost required to transform array into single element.

Constraints:
1<=T<=100
1<=N<=1000
1<=Ai<=10^5

Example:
Input:

1
3
4 2 5
Output:
4

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth
Author: saksham seth

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.