I’m using a similar approach but getting WA
The code is in python and intended.
Can anyone help?
while True:
x = int(input())
if(x==-1):
break
s = []
count = 0
for i in range(1,x+1):
j = int(input())
s.append(j)
if(sum(s)%x != 0):
print(-1)
break
av = sum(s)/x
for k in s:
if(k>av):
count = count+(k-av)
print (int(count))
`indent preformatted text by 4 spaces`