#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
const int MAXN=16;
int a[MAXN],i,j,k,ans,l,r,n;
int main()
{
freopen("eight.in","r",stdin);
freopen("eight.out","w",stdout);
scanf("%d",&n);
for (i=1;i<=n;i++)
scanf("%d",&a[i]);
ans=0;
scanf("%d%d",&l,&r);
while (l%8!=0) l++;
for (i=l;i<=r;i+=8)
{
for (j=1;j<=n;j++)
if (i%a[j]==0) break;
if (j==n+1) ans++;
}
printf("%d\n",ans);
return 0;
}