program zzn;
var
l,r,n,i,j,sum,ans:longint;
a,ne:array[1..50]of longint;
procedure swap(var a,b:longint);
var
t:longint;
begin
t:=a;
a:=b;
b:=t;
end;
procedure init;
begin
assign(input,'groupa.in');
reset(input);
assign(output,'groupa.out');
rewrite(output);
readln(n);
sum:=0;
for i:=1 to n do
begin
read(a[i]);
inc(sum,a[i]);
end;
readln;
readln(l,r);
for i:=1 to n-1 do
for j:=i+1 to n do if a[i]>a[j] then swap(a[i],a[j]);
end;
procedure closef;
begin
close(input);
close(output);
end;
procedure main;
var
t1,t2:longint;
begin
if (sum div n<l)or(sum div n>r ) then
begin
writeln(-1);
exit;
end;
if (a[1]>=l)and(a[n]<=r) then
begin
writeln(0);
exit;
end;
ans:=0;
for i:=1 to n do
begin
if a[i]>r then ne[i]:=a[i]-r;
if a[i]<l then ne[i]:=a[i]-l;
end;
t1:=0;t2:=0;
for i:=1 to n do
if ne[i]>0 then inc(t1,ne[i]) else inc(t2,abs(ne[i]));
if t1>t2 then ans:=t1 else ans:=t2;
writeln(ans);
end;
begin
init;
main;
closef;
end.