program eight;
var
p:array [1..15] of longint;
n,a,b,s:longint;
f1,f2:text;
procedure init;
var i:longint;
begin
assign(f1,'eight.in'); reset(f1);
assign(f2,'eight.out'); rewrite(f2);
readln(f1,n);
for i:=1 to n do
read(f1,p[i]);
readln(f1);
readln(f1,a,b);
close(f1);
end;
function ok(x:longint):boolean;
var i:longint;
begin
if x mod 8=0 then begin
for i:=1 to n do
if x mod p[i]=0 then begin
ok:=false;
exit;
end;
ok:=true;
end
else ok:=false;
end;
procedure play;
var i:longint;
begin
s:=0;
for i:=a to b do if ok(i)=true then s:=s+1;
end;
procedure print;
begin
writeln(f2,s);
close(f2);
end;
begin
init;
play;
print;
end.