program eight;
var
num:array [1..15] of integer;
t,x,y,n,nx,ny,a,b,tmp,i,sum:longint;
procedure print;
begin
writeln(0);
close (output);
halt;
end;
begin
assign (input,'eight.in');
reset (input);
assign (output,'eight.out');
rewrite (output);
readln (n);
for i:=1 to n do begin
read (num[i]);
if (num[i]=1) or (num[i]=2) or (num[i]=4) or (num[i]=8) then print;
end;
readln (X,Y);
sum:=(y div 8)-(x div 8);
for i:=1 to n do if num[i] mod 8<>0 then begin
a:=num[i];b:=8;
if a<b then begin
tmp:=a;
a:=b;
b:=tmp;
end;
while b>0 do begin
tmp:=a mod b;
a:=b;
b:=tmp;
end;
t:=num[i]*8 div a;
nx:=x div t+1;
ny:=y div t;
sum:=sum-(ny-nx+1);
end;
close (input);
writeln (sum);
close (output);
end.