Candies

2

1 votes
Easy
Problem

Given N bags of candies where each bag contains Ai number of candies in it. Your task is to use minimum number of steps to make number of candies in each bag equal. In each step you can remove one candy from any bag and transfer it to another bag.

Input
First line contains T number of test cases. First line of each test case contains N (number of bags). Next lines contains N integers separated by a single space.

Output
Print minimum number of steps to make candies in each bag equal in number. If it is impossible to make number of candies same in each bag print -1.

Constraints
1 <= T <= 104
1 <= N <= 104
1 <= Ai <= 109

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?