program ex;
var
c:array[1..15] of longint;
x,a,b,n,i,j:longint;
pd:boolean;
procedure init;
begin
assign(input,'eight.in');
assign(output,'eight.out');
reset(input);
rewrite(output);
readln(n);
for i:=1 to n do read(c[i]);
readln(a,b);
close(input);
end;
begin
init;
for i:=1 to n do
if ((c[i]=2)or(c[i]=4)) then begin writeln('0');close(output);halt;end;
x:=0;
for i:=a to b do
begin
if ((i mod 8)=0) then
begin
pd:=true;
for j:=1 to n do if (i mod c[j]=0) then
begin
pd:=false;
break;
end;
if pd then inc(x);
end;
end;
writeln(x);
close(output);
end.