COMPUTERS IN SCHOOL
In the city, each of the N schools was supposed to receive a computer lab with an equal number of computers. However, due to a mistake by the suppliers, the first school received a[1]
computers, the second school received a[2]
, and so on, up to the Nth school, which received a[N]
computers.
Your task is to determine the minimum number of computers that need to be moved between schools to achieve an equal distribution across all schools. If it's impossible to achieve equal distribution, output -1.
Input
The first line contains the integer N, representing the number of schools. The second line contains N integers, which are the elements of the array a, indicating the number of computers delivered to each school. Each value is a natural number and does not exceed 100.
Output
Output the minimum number of computer transfers needed to achieve equal distribution, or -1 if equal distribution is not possible.