program zzn;
var
ans,l,r,fac,n,i,j,a,b:longint;
nn:array[1..15]of longint;
procedure init;
begin
assign(input,'eight.in');
reset(input);
assign(output,'eight.out');
rewrite(output);
readln(n);
for i:=1 to n do read(nn[i]);
readln(a,b);
end;
procedure closef;
begin
close(input);
close(output);
end;
function can(x:longint):boolean;
var
i:integer;
begin
for i:=1 to n do if x mod nn[i]=0 then exit(false);
if x mod 8<>0 then exit(false);
exit(true);
end;
procedure main;
begin
ans:=0;
for i:=a to b do
begin
if can(i) then
inc(ans);
end;
writeln(ans);
end;
function can2(x:longint):boolean;
var
i:longint;
begin
for i:=1 to n do if x mod nn[i]=0 then exit(false);
exit(true);
end;
procedure main2;
var
l,r,i:longint;
begin
l:=a div 8;
if l*8<a then inc(l);
r:=b div 8;
ans:=0;
for i:=l to r do
begin
fac:=8*i;
if can2(fac) then
inc(ans);
end;
writeln(ans);
end;
begin
init;
if b<=100000 then main else
main2;
closef;
end.