program aa;
var
a,b,c,d,e,f,i,j,n,m,max,sum:longint;
l:array[1..10000]of integer;
f1,f2:text;
begin
assign(f1,'move.in');
assign(f2,'move.out');
reset(f1);
rewrite(f2);
readln(f1,n);
sum:=0;max:=0;
for i:=1 to n do
begin
read(f1,l[i]);
sum:=sum+l[i];
end;
sum:=sum div n;
for i:=1 to n do
l[i]:=l[i]-sum;
i:=1;j:=n;
for i:=1 to n do
if l[i]>0 then max:=max+l[i];
writeln(f2,max);
close(f1);close(f2);
end.