program groupa;
var
n,i,j,l,r,t,h,m,min,max:longint;
a,b:array[1..50] of longint;
begin
assign(input,'groupa.in');
assign(output,'groupa.out');
reset(input);
rewrite(output);
readln(n);
for i:=1 to n do read(a[i]);
readln(l,r);
for i:=1 to n do b[i]:=a[i]-l;
for i:=1 to n do h:=h+b[i];
if (h>(n*(r-l))) or (h<0)
then begin
writeln(-1);
close(input);
close(output);
halt;
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if b[i]<b[j] then begin
t:=b[i];
b[i]:=b[j];
b[j]:=t;
end
else begin
t:=b[i];
b[i]:=b[j];
b[j]:=t;
end;
for i:=1 to n do
if b[i]>(r-l) then max:=max+b[i]-(r-l)
else if b[i]<0 then min:=min+abs(b[i]);
if max>min then m:=max
else m:=min;
writeln(m);
close(input);
close(output);
end.