program aa;
var
head,tail,x:integer;
a:array[1..100] of integer;
f,f1:text;
k:real;
n,l,r,s,v,sort:integer;
i,j:integer;
function zai(b:integer):boolean;
begin
if (b<=r)and(b>=l) then zai:=true
else zai:=false;
end;
begin
k:=0;
s:=0;
assign(f,'groupa.in'); assign(f1,'groupa.out');
reset(f);
rewrite(f1);
readln(f,n);
for i:=1 to n do
read(f,a[i]);
readln(f);
read(f,l,r);
for i:=1 to n do
k:=k+a[i];
if (k/n<l) or (k/n>r) then
begin
write(f1,'-1');
end
else
begin
for i:=1 to n do
if zai(a[i]) then inc(s);
if s=n then
begin
write(f1,0);
end
else
begin
for i:=1 to n-1 do
for j:=i to n do
if a[i]<a[j] then begin
sort:=a[i];
a[i]:=a[j];
a[j]:=sort;
end;
head:=1;
tail:=n;
repeat
repeat
if (a[head]>l)or (a[tail]<l) then
begin
dec(a[head]);
inc(a[tail]);
x:=x+1;
end;
until
(a[head]>=l) or (a[tail]>=l);
if a[head]<=l then inc(head);
if a[tail]>=l then dec(tail);
until
head=tail;
v:=a[head]-r;
write(f1,x+v);
end;
end;
close(f);close(f1);
end.