### Minimum and Maximum

#### Description:

" 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 :

#include<stdio.h>

int main()

{

int t;

long long int i,small,n,a;

long long int sum;

scanf("%d",&t);

while(t--)

{

scanf("%lld",&n);

for(i=0;i<n;i++)

scanf("%lld",&a[i]);

small=a;

for(i=1;i<n;i++)

{

if(a[i]<small)

small=a[i];

}

sum=1;

sum=small*(n-1);

printf("%lld\n",sum);

}

return 0;

}