Equalization of an array
##### Submissions: 571   Accuracy: 40.84%   Difficulty: Basic   Marks: 1

Given an array of integers, the task is to count minimum number of operations to equalize the array i.e., to make all array elements same. To equalize an array, we need to move values from higher numbers to smaller numbers. Number of operations is equal to number of movements.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. First line of each test case contains an Integer N denoting size of array and the second line contains N space separated elements.

Output:
For each test case, print the minimum number of operations. And print "-1", if it is not possible to equalize the array.

Constraints:
1<=T<=100
1<=N<=105

0<=A[i]<=105

Example:
Input:

2
5
1 3 2 0 4
3
1 7 1
Output:
3
4

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

Contributor: Arun Tyagi
Author: arun03

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.