Chef has an array
having elements. Chef wants to make all the elements of the array equal by repeating the following move.
- Choose any integer between and (inclusive). Then choose distinct indices , and increase the values of by .
Find the minimum number of moves required to make all the elements of the array equal.
Input Format
- The first line contains denoting the number of test cases. Then the test cases follow.
- The first line of each test case contains a single integer denoting the number of elements in .
- The second line of each test case contains space separated integers .
Output Format
For each test case, print a single line containing one integer denoting the minimum number of moves required to make all the elements of the array equal.
Constraints
- The sum of over all test cases does not exceed .
Sample Input 1
2
3
1 3 1
3
2 2 2
Sample Output 1
2
0
Explanation
Test Case : In the first move, Chef can choose , and choose the indices . After increasing and by , the array will become . In the second move, Chef can choose , and choose the indices . After increasing and by , the array will become , and hence all the elements become equal.
Test Case : All the elements of the array are equal, hence no move is required.
ConversionConversion EmoticonEmoticon