Christy is interning at HackerRank. One day she has to distribute some chocolates to her colleagues. She is biased towards her friends and plans to give them more than the others. One of the program managers hears of this and tells her to make sure everyone gets the same number.
To make things difficult, she must equalize the number of chocolates in a series of operations. For each operation, she can give chocolates to all but one colleague. Everyone who gets chocolate in a round receives the same number of pieces.
For example, assume the starting distribution is . She can give bars to the first two and the distribution will be . On the next round, she gives the same two bar each, and everyone has the same number: .
Given a starting distribution, calculate the minimum number of operations needed so that every colleague has the same number of chocolates.
The first line contains an integer , the number of testcases.
Each testcase has lines.
- The first line contains an integer , the number of colleagues.
- The second line contains n space-separated integers denoting the number of chocolates each colleague has.
Number of initial chocolates each colleague has <
Print the minimum number of operations needed for each test case, one to a line.
2 2 3 7
Add to all but the 3rd element
Add to all but the 4th element
Two operations were required.
Sample Input 1
10 7 12
Sample Output 1
Add to the first two elements
Add to the last two elements