program groupa;
var
a:array [1..50] of longint;
n,x,y,ans,i,sum:longint;
begin
assign (input,'groupa.in');
reset (input);
readln (n);sum:=0;
for i:=1 to n do begin
read (a[i]);
sum:=sum+a[i];
end;
readln (x,y);
close (input);
assign (output,'groupa.out');
rewrite (output);
if sum div n>y then begin
writeln (-1);
end
else begin
if sum div n=y then begin
ans:=0;
for i:=1 to n do begin
ans:=ans+abs(a[i]-sum div n);
end;
writeln (ans);
end;
end;
close (output);
end.