program eight;
var n,i,m,t,s,a,b,x:longword;
C:array of longword;
function get(x:longword):longword;
begin
if x mod 8=0 then exit(x);
if x mod 4=0 then exit(x*2);
if x mod 2=0 then exit(x*4);
exit(x*8);
end;
begin
assign(input,'eight.in'); reset(input);
assign(output,'eight.out'); rewrite(output);
readln(n);
SetLength(C,n+1);
for i:=1 to n do
begin
read(x);
C[i]:=get(x);
end;
readln(a,b);
m:=(b div 8)-(a div 8);
if a mod 8=0 then m+=1;
for i:=1 to n do
begin
t:=C[i];
s:=(b div t)-(a div t);
if a mod t=0 then s+=1;
m-=s;
end;
writeln(m);
close(input); close(output);
end.