Minimum and Maximum


" Chef loves to play with arrays by himself. Today, he has an array A consisting of N distinct integers. He wants to perform the following operation on his array A. Select 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. 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. " Test Case 1 Input (stdin) 1 2 3 4 Expected Output 3 Test Case 2 Input (stdin) 1 5 1 2 3 4 5

Program :


int main()


    int t;

    long long int i,small,n,a[50000];

    long long int sum;

















    return 0;