var
n,i,x,y,total:longint;
a:array[0..50]of longint;
function yes(k:longint):boolean;
var
i:longint;
begin
if k mod 8<>0 then exit(false);
for i:=1 to n do
if k mod a[i]=0 then exit(false);
exit(true);
end;
begin
assign(input,'eight.in'); reset(input);
assign(output,'eight.out'); rewrite(output);
readln(n);
for i:=1 to n do read(a[i]);
readln(x,y);
for i:=x to y do
if yes(i) then inc(total);
writeln(total);
close(input);
close(output);
end.