program xxxx;
var l,i,r,x,w,j:int64;
p,n:longint;
a:array[1..15] of int64;
begin
assign(input,'eight.in');
reset(input);
assign(output,'eight.out');
rewrite(output);
read(n);
for p:=1 to n do
read(a[p]);
read(l,r);
i:=l;
repeat
begin
x:=1;
if (i mod 8)=0 then
begin
for p:=1 to n do
if (i mod a[p])=0 then
begin
x:=0;
break;
end;
if x<>0 then
begin
inc(w);
inc(i);
continue;
end
else
begin
inc(i);
continue;
end;
end
else
inc(i);
end
until
i>r;
write(w);
close(input);
close(output);
end.