program groupa;
var a,b,tot:int64;
g:array[1..100]of longint;
l,r,t,k,m,n,i,j:longint;
begin
assign(input,'groupa.in');
reset(input);
assign(output,'groupb.out');
rewrite(output);
readln(n);
for t:=1 to n do
begin
read(g[t]);
tot:=tot+g[t];
end;
readln;
readln(l,r);
if (tot div n<l)or(tot div n>r)or(tot div n=r)and(tot mod n>0) then
begin
writeln(-1);
close(output);
halt;
end;
for t:=1 to n do
begin
if g[t]<l then a:=a+l-g[t]
else if g[t]>r then b:=b+g[t]-r;
end;
if a>b then writeln(a)
else writeln(b);
close(output);
end.