program aa;
var
swap:longint;
ar:array[1..15] of longint;
n:shortint;
i,j,a,b,x:longint;
f,f1:text;
function zhen(x:integer):boolean;
var
j:integer;
k:integer;
begin
zhen:=true;
for j:=1 to n do
if (i mod ar[j] =0) then begin
zhen:=false;
break;
end;
end;
begin
assign(f,'eight.in');assign(f1,'eight.out');
reset(f);
rewrite(f1);
readln(f,n);
for i:=1 to n do
read(f,ar[i]);
readln(f);
read(f,a,b);
for i:=1 to n-1 do
for j:=i to n do
if ar[i]>ar[j] then begin
swap:=ar[i];
ar[i]:=ar[j];
ar[j]:=swap;
end;
for i:=a to b do
if (i mod 8=0)and zhen(ar[j]) then
inc(x);
write(f1,x);
close(f);close(f1);
end.