var
n,up,down,i,j,total:longint;
a:array[0..1000]of longint;
procedure sort(l,r: longint);
var
i,j,x,y: longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2];
repeat
while a[i]<x do
inc(i);
while x<a[j] do
dec(j);
if not(i>j) then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
j:=j-1;
end;
until i>j;
if l<j then
sort(l,j);
if i<r then
sort(i,r);
end;
procedure init;
var
i:longint;
x:real;
begin
assign(input,'groupa.in'); reset(input);
assign(output,'groupa.out'); rewrite(output);
readln(n);
for i:=1 to n do read(a[i]);
readln(down,up);
for i:=1 to n do x:=x+a[i];
x:=x/n;
if (x<down)or(x>up) then
begin
writeln(-1);
close(input);
close(output);
halt;
end;
end;
function yes:boolean;
var
i:longint;
begin
for i:=1 to n do
if (a[i]<down)or(a[i]>up) then exit(false);
exit(true);
end;
begin
init;
repeat
sort(1,n);
for i:=1 to n do
begin
if a[i]<down then
begin
j:=n;
while a[i]<down do
begin
dec(a[j]);
inc(a[i]);
if a[j]=down then dec(j);
inc(total);
end;
break;
end
else if a[i]>up then
begin
j:=1;
while a[i]>up do
begin
dec(a[i]);
inc(a[j]);
if a[j]=up then inc(j);
inc(total);
end;
break;
end;
end;
until yes;
writeln(total);
close(input);
close(output);
end.