#P2134. sweets

sweets

The president of LanXiang buys N packets of sweets for his students.However, the number of sweets in each packet is not same. For the sake of fairness, the president decides to move some sweets between the packet to make them all equal. 
As he has two hands, he must always carry exactly two sweets: one in each hand. Thus, he can only make one type of an action: pick up two sweets from one of the packets and carry both of them to some other packets. Of course,he is not allowed to remove a packet completely. Therefore, he cannot pick up sweets from a packet that currently contains fewer than 3 sweets.
Now, the president want to know the minimum number of actions he has to perform in order to make all packets equal. 

Input

There are multiple test cases.
For each test case, the first line contains an integer N, represent there are N packets of sweets. The second line contains N integers Ai, it indicates the number of sweets in ith packet. (1≤N,Ai≤100)

Output

For each case, print an integer which represents the minimum number of actions the president has to perform in order to make all packets equal. If it is impossible to make all packets equal using the allowed type of actions, print “-1” instead.

Sample Input

2
1 5
4
7 15 9 5

Sample Output

1
3

HINT

Source