program ex;
var
a:array[1..1000000] of longint;
z,xj,xc,n,i,r,l:longint;
c:real;
procedure init;
begin
assign(input,'groupa.in');
assign(output,'groupa.out');
reset(input);
rewrite(output);
readln(n);
z:=0;
for i:=1 to n do begin read(a[i]);z:=z+a[i];end;
readln(l,r);
close(input);
xj:=0;
xc:=0;
end;
begin
init;
c:=z/n;
if (c>=l) and (c<=r) then
begin
for i:=1 to n do
begin
if a[i]>r then xc:=xc+(a[i]-r);
if a[i]<l then xj:=xj+(l-a[i]);
end;
end
else begin writeln('-1');close(output);halt;end;
if (xc>=xj) then writeln(xc) else writeln(xj);
close(output);
end.