#include <bits/stdc++.h>
using namespace std;
#define oo 1000000007
#define ll long long
#define F        first
#define S        second
const int N = 1002;
bool visited[N]; vector<int>ans, adj[N];
bool dis[N][N];
void dfs(int node){
    visited[node]=1;
    ans.push_back(node);
    for(int i=0;i<adj[node].size();i++){
        int ch=adj[node][i];
        if(!visited[ch]){
            dfs(ch);
        }
    }
}
bool DisLike(){
    for(int i=0;i<ans.size();i++)
    for(int j=i+1;j<ans.size();j++){
        if(dis[ans[i]][ans[j]])
            return 1;
    }
    return 0;
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
    int n, k, m;
    memset(visited, 0, sizeof visited);
    memset(dis, 0, sizeof dis);
    scanf("%d%d", &n, &k);
    for(int i=0;i<k;i++){
        int f, t;
        scanf("%d%d", &f, &t);
        adj[f].push_back(t), adj[t].push_back(f);
    }
    scanf("%d", &m);
    for(int i=0;i<m;i++){
        int f, t;
        scanf("%d%d", &f, &t);
        dis[f][t] = dis[t][f] = 1;
    }
    int Max=-oo;
    for(int i=1;i<=n;i++){
        if(!visited[i]){
            ans.clear();
            dfs(i);
            if(!DisLike()){
                Max = max(Max, (int)ans.size());
            }
        }
    }
    cout << (Max == -oo? 0 : Max);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 2000002;
#define ll long long int

//Implementation of DSU
int parent[N], sz[N];
int findSet(int i) {
    if(parent[i] == i)
        return i;
    return parent[i] = findSet(parent[i]);
}
bool isSameSet(int i, int j) {
    return findSet(i) == findSet(j);
}
void makeEdge(int i, int j) {
    if(isSameSet(i, j))
        return;
    i = parent[i], j = parent[j];
    if(sz[i] < sz[j]) {
        parent[i] = parent[j];
        sz[j] += sz[i];
    } else {
        parent[j] = parent[j];
        sz[i] += sz[j];
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("/home/riham/ClionProjects/Problems/input.txt", "r", stdin);
//    freopen("/home/riham/ClionProjects/Problems/output.txt", "w", stdout);
#endif // ONLINE_JUDGE
    int n, k, m;
    int f, t;
    scanf("%d%d", &n, &k);
    for(int i=0;i<n;i++) {
        parent[i] = i;
        sz[i] = 1;
    }
    for(int i=0;i<k;i++) {
        scanf("%d%d", &f, &t);
        makeEdge(f-1, t-1);
    }
    scanf("%d", &m);
    for(int i=0;i<m;i++) {
        scanf("%d%d", &f, &t);
        f = findSet(f-1), t = findSet(t-1);
        if(sz[f] > sz[t]) sz[t] = 0;
        else sz[f] = 0;
    }
    printf("%d", *max_element(sz, sz+n));
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define oo 1000000007
#define ll long long
#define F        first
#define S        second
const int N = 2004;
bool visited[N]; vector<int>ans, adj[N];
bool dis[N][N];
void dfs(int node){
    visited[node]=1;
    ans.push_back(node);
    for(int i=0;i<adj[node].size();i++){
        int ch=adj[node][i];
        if(!visited[ch]){
            dfs(ch);
        }
    }
}
bool DisLike(){
    for(int i=0;i<ans.size();i++)
    for(int j=i+1;j<ans.size();j++){
        if(dis[ans[i]][ans[j]])
            return 1;
    }
    return 0;
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
    int n, k, m;
    memset(visited, 0, sizeof visited);
    memset(dis, 0, sizeof dis);
    scanf("%d%d", &n, &k);
    for(int i=0;i<k;i++){
        int f, t;
        scanf("%d%d", &f, &t);
        adj[f].push_back(t), adj[t].push_back(f);
    }
    scanf("%d", &m);
    for(int i=0;i<m;i++){
        int f, t;
        scanf("%d%d", &f, &t);
        dis[f][t] = dis[t][f] = 1;
    }
    int Max=-oo;
    for(int i=1;i<=n;i++){
        if(!visited[i]){
            ans.clear();
            dfs(i);
            if(!DisLike()){
                Max = max(Max, (int)ans.size());
            }
        }
    }
    cout << (Max == -oo? 0 : Max);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

const int MAXN = 5000;
int p[MAXN], size[MAXN], n, m;

int find_set( int v )
{
	return v == p[v] ? v : p[v] = find_set( p[v] );
}
void union_set( int x, int y )
{
	x = find_set( x );
	y = find_set( y );
	if( x != y ){
		if( size[x] < size[y] ) swap( x, y );
		p[x] = y;
		size[y] += size[x];
	}
}
int main()
{
        cin >> n >> m;
        for( int i = 1; i <= n; i++ ) size[i] = 1, p[i] = i;
        while( m-- ){
        	int x, y;
        	cin >> x >> y;
        	union_set( x, y );
        }
        int mx = 0;
        cin >> m;
        while( m-- ){
        	int x, y;
        	cin >> x >> y;
        	if( find_set( x ) == find_set( y ) )
        		size[find_set( x )] = 0;
        }
        for( int i = 1; i <= n; i++ ){
        	mx = max( mx, size[find_set( i )] );
        }
        cout << mx << endl;
}


#include<bits/stdc++.h>

using namespace std;

long long int dsu[100005],i,j,k;
map<long long int,long long int>m1;
map<long long int,bool>m2,m3,m4;

void ds(long long int n){
    for(i=1;i<=n;i++){
        dsu[i]=-1;
        m1[i]=1;m2[i]=true;
    }
}
long long int parent(long long int n){

    if(dsu[n]<0)
        return n;

    long long int b=parent(dsu[n]);

    if(n!=b){
       dsu[n]=b;
    }

    return b;
}
bool dis_find(long long int x,long long int y){

    long long int p_x=parent(x);
    long long int p_y=parent(y);

    return (x==y);
}
long long int dsw(long long int x){
    return -1*dsu[x];
}
long long int ds_union(long long int x,long long int y){

    long long int p_x=parent(x);
    long long int p_y=parent(y);

    if(p_x!=p_y){
        if(dsw(p_x)>=dsw(p_y)){

            dsu[p_x]+=dsu[p_y];
            dsu[p_y]=p_x;

            m1[p_x]=m1[p_x]+m1[p_y];
            m2[p_x]=true;m2[p_y]=false;

            return dsw(p_x);
        }
        else{
            dsu[p_y]+=dsu[p_x];
            dsu[p_x]=p_y;

            m1[p_y]=m1[p_x]+m1[p_y];
            m2[p_y]=true;m2[p_x]=false;

            return dsw(p_y);
        }
    }
}
int main(){

    long long int n,m,k,i,j,l,p,q;

    cin>>n;

    ds(n);

    cin>>m;

    while(m--){
        cin>>p>>q;
        ds_union(p,q);
    }

    cin>>l;

    vector<pair<long long int,long long int> >v1;

    while(l--){

        cin>>p>>q;

        long long int p1=parent(p),p2=parent(q);

        if(p1==p2){
            m2[p1]=false;
            m1[p1]=0;
        }
        else{
            v1.push_back(make_pair(p,q));
        }
    }

    for(l=0;l<v1.size();l++){

        long long int p1=parent(v1[l].first),p2=parent(v1[l].second);
        if(m1[p1]<=m1[p2]){
            m1[p1]=0;
            m2[p1]=false;
        }
    }

    long long int count1=0;

    for(i=1;i<=n;i++){
        //cout<<"i:"<<i<<",m1:"<<m1[i]<<",m2:"<<m2[i]<<"\n";
        if(m2[i])
            count1=max(count1,m1[i]);
    }

    cout<<count1<<"\n";

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

long long int dsu[100005],i,j,k;
map<long long int,long long int>m1;
map<long long int,bool>m2,m3,m4;

void ds(long long int n){
    for(i=1;i<=n;i++){
        dsu[i]=-1;
        m1[i]=1;
    }
}
long long int parent(long long int n){

    if(dsu[n]<0)
        return n;

    long long int b=parent(dsu[n]);

    if(n!=b){
       dsu[n]=b;
    }

    return b;
}
bool dis_find(long long int x,long long int y){

    long long int p_x=parent(x);
    long long int p_y=parent(y);

    return (x==y);
}
long long int dsw(long long int x){
    return -1*dsu[x];
}
long long int ds_union(long long int x,long long int y){

    long long int p_x=parent(x);
    long long int p_y=parent(y);

    if(p_x!=p_y){
        if(dsw(p_x)>=dsw(p_y)){

            dsu[p_x]+=dsu[p_y];
            dsu[p_y]=p_x;

            m1[p_x]=m1[p_x]+m1[p_y];
            m2[p_x]=true;m2[p_y]=false;

            return dsw(p_x);
        }
        else{
            dsu[p_y]+=dsu[p_x];
            dsu[p_x]=p_y;

            m1[p_y]=m1[p_x]+m1[p_y];
            m2[p_y]=true;m2[p_x]=false;

            return dsw(p_y);
        }
    }
}
int main(){

    long long int n,m,k,i,j,l,p,q;

    cin>>n;

    ds(n);

    cin>>m;

    while(m--){
        cin>>p>>q;
        ds_union(p,q);
    }

    cin>>l;

    vector<pair<long long int,long long int> >v1;

   /*  for(i=1;i<=n;i++){
        if(m2[i])
            cout<<"i:"<<i<<",m1:"<<m1[i]<<",m2:"<<m2[i]<<"\n";
    }

    cout<<"\n\n";*/
    while(l--){

        cin>>p>>q;

        long long int p1=parent(p),p2=parent(q);

        if(p1==p2){
        //    cout<<"p1:"<<p1<<",p2:"<<p2<<"\n";
        //    cout<<"before m2:"<<m2[p1]<<",m1:"<<m1[p1]<<"\n";
            m2[p1]=false;
            m1[p1]=0;
        //    cout<<"\n\nAfter m2:"<<m2[p1]<<",m1:"<<m1[p1]<<"\n";
        }
        else{
            v1.push_back(make_pair(p,q));
        }
    }

    for(l=0;l<v1.size();l++){

        long long int p1=parent(v1[l].first),p2=parent(v1[l].second);

        /*cout<<"p1:"<<p1<<",p2:"<<p2<<"\n";
        cout<<"Before m1_1:"<<m1[p1]<<",m1_2:"<<m1[p2]<<"\n";
        cout<<"In 2 Before m2_1:"<<m2[p1]<<",m2_2:"<<m2[p2]<<"\n";*/
        if(m1[p1]<m1[p2]){
            m1[p1]=0;
            m2[p1]=false;
        }
        /*cout<<"After m1_1:"<<m1[p1]<<",m1_2:"<<m1[p2]<<"\n";
        cout<<"In 2 Before m2_1:"<<m2[p1]<<",m2_2:"<<m2[p2]<<"\n";*/
    }

    long long int count1=0;

    for(i=1;i<=n;i++){
        if(m2[i])
            count1=max(count1,m1[i]);
    }

    if(n!=0)
        cout<<max(1,count1)<<"\n";
    else
        cout<<count1<<"\n";

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

long long int dsu[100005],i,j,k;
map<long long int,long long int>m1;
map<long long int,bool>m2;

void ds(long long int n){
    for(i=1;i<=n;i++){
        dsu[i]=-1;
        m1[i]=1;
    }
}
long long int parent(long long int n){

    if(dsu[n]<0)
        return n;

    long long int b=parent(dsu[n]);

    if(n!=b){
       dsu[n]=b;
    }

    return b;
}
bool dis_find(long long int x,long long int y){

    long long int p_x=parent(x);
    long long int p_y=parent(y);

    return (x==y);
}
long long int dsw(long long int x){
    return -1*dsu[x];
}
long long int ds_union(long long int x,long long int y){

    long long int p_x=parent(x);
    long long int p_y=parent(y);

    if(p_x!=p_y){
        if(dsw(p_x)>=dsw(p_y)){

            dsu[p_x]+=dsu[p_y];
            dsu[p_y]=p_x;

            m1[p_x]=m1[p_x]+m1[p_y];
            m2[p_x]=true;m2[p_y]=false;

            return dsw(p_x);
        }
        else{
            dsu[p_y]+=dsu[p_x];
            dsu[p_x]=p_y;

            m1[p_y]=m1[p_x]+m1[p_y];
            m2[p_y]=true;m2[p_x]=false;

            return dsw(p_y);
        }
    }
}
int main(){

    long long int n,m,k,i,j,l,p,q;

    cin>>n;

    ds(n);

    cin>>m;

    while(m--){
        cin>>p>>q;
        ds_union(p,q);
    }

    cin>>l;

    vector<pair<long long int,long long int> >v1;

   /*  for(i=1;i<=n;i++){
        if(m2[i])
            cout<<"i:"<<i<<",m1:"<<m1[i]<<",m2:"<<m2[i]<<"\n";
    }

    cout<<"\n\n";*/
    while(l--){

        cin>>p>>q;

        long long int p1=parent(p),p2=parent(q);

        if(p1==p2){
        //    cout<<"p1:"<<p1<<",p2:"<<p2<<"\n";
        //    cout<<"before m2:"<<m2[p1]<<",m1:"<<m1[p1]<<"\n";
            m2[p1]=false;
            m1[p1]=0;
        //    cout<<"\n\nAfter m2:"<<m2[p1]<<",m1:"<<m1[p1]<<"\n";
        }
        else{
            v1.push_back(make_pair(p,q));
        }
    }

    for(l=0;l<v1.size();l++){

        long long int p1=parent(v1[l].first),p2=parent(v1[l].second);

        /*cout<<"p1:"<<p1<<",p2:"<<p2<<"\n";
        cout<<"Before m1_1:"<<m1[p1]<<",m1_2:"<<m1[p2]<<"\n";
        cout<<"In 2 Before m2_1:"<<m2[p1]<<",m2_2:"<<m2[p2]<<"\n";*/
        if(m1[p1]<m1[p2]){
            m1[p1]=0;
            m2[p1]=false;
        }
        /*cout<<"After m1_1:"<<m1[p1]<<",m1_2:"<<m1[p2]<<"\n";
        cout<<"In 2 Before m2_1:"<<m2[p1]<<",m2_2:"<<m2[p2]<<"\n";*/
    }

    long long int count1=0;

    for(i=1;i<=n;i++){
        if(m2[i])
            count1=max(count1,m1[i]);
    }

    cout<<count1<<"\n";

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

long long int dsu[100005],i,j,k;
map<long long int,long long int>m1;
map<long long int,bool>m2,m3,m4;

void ds(long long int n){
    for(i=1;i<=n;i++){
        dsu[i]=-1;
        m1[i]=1;
    }
}
long long int parent(long long int n){

    if(dsu[n]<0)
        return n;

    long long int b=parent(dsu[n]);

    if(n!=b){
       dsu[n]=b;
    }

    return b;
}
bool dis_find(long long int x,long long int y){

    long long int p_x=parent(x);
    long long int p_y=parent(y);

    return (x==y);
}
long long int dsw(long long int x){
    return -1*dsu[x];
}
long long int ds_union(long long int x,long long int y){

    long long int p_x=parent(x);
    long long int p_y=parent(y);

    if(p_x!=p_y){
        if(dsw(p_x)>=dsw(p_y)){

            dsu[p_x]+=dsu[p_y];
            dsu[p_y]=p_x;

            m1[p_x]=m1[p_x]+m1[p_y];
            m2[p_x]=true;m2[p_y]=false;

            return dsw(p_x);
        }
        else{
            dsu[p_y]+=dsu[p_x];
            dsu[p_x]=p_y;

            m1[p_y]=m1[p_x]+m1[p_y];
            m2[p_y]=true;m2[p_x]=false;

            return dsw(p_y);
        }
    }
}
int main(){

    long long int n,m,k,i,j,l,p,q;

    cin>>n;

    ds(n);

    cin>>m;

    while(m--){
        cin>>p>>q;
        ds_union(p,q);
    }

    cin>>l;

    vector<pair<long long int,long long int> >v1;

   /*  for(i=1;i<=n;i++){
        if(m2[i])
            cout<<"i:"<<i<<",m1:"<<m1[i]<<",m2:"<<m2[i]<<"\n";
    }

    cout<<"\n\n";*/
    while(l--){

        cin>>p>>q;

        long long int p1=parent(p),p2=parent(q);

        if(p1==p2){
        //    cout<<"p1:"<<p1<<",p2:"<<p2<<"\n";
        //    cout<<"before m2:"<<m2[p1]<<",m1:"<<m1[p1]<<"\n";
            m2[p1]=false;
            m1[p1]=0;
        //    cout<<"\n\nAfter m2:"<<m2[p1]<<",m1:"<<m1[p1]<<"\n";
        }
        else{
            v1.push_back(make_pair(p,q));
        }
    }

    for(l=0;l<v1.size();l++){

        long long int p1=parent(v1[l].first),p2=parent(v1[l].second);

        /*cout<<"p1:"<<p1<<",p2:"<<p2<<"\n";
        cout<<"Before m1_1:"<<m1[p1]<<",m1_2:"<<m1[p2]<<"\n";
        cout<<"In 2 Before m2_1:"<<m2[p1]<<",m2_2:"<<m2[p2]<<"\n";*/
        if(m1[p1]<m1[p2]){
            m1[p1]=0;
            m2[p1]=false;
        }
        /*cout<<"After m1_1:"<<m1[p1]<<",m1_2:"<<m1[p2]<<"\n";
        cout<<"In 2 Before m2_1:"<<m2[p1]<<",m2_2:"<<m2[p2]<<"\n";*/
    }

    long long int count1=0;

    for(i=1;i<=n;i++){
        if(m2[i])
            count1=max(count1,m1[i]);
    }

    if(n!=0)
        cout<<max((long long int)1,count1)<<"\n";
    else
        cout<<count1<<"\n";

    return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define ld long douroote
#define pb push_back
#define ll long long
#define INF 0x7f7f7f7f
#define sc(a) scanf("%d",&a)
#define scll(a) scanf("%lld",&a)
#define scc(a) scanf(" %c",&a)
#define scs(a) scanf(" %s",a)
#define me(a,b) memset(a,b,sizeof a)
#define all(a) a.begin(),a.end()
#define allr(a,n) a,a+n
#define loop(a,s,e) for(ll a=s;a<=e;a++)
#define read_arr(a,s,n) for(ll i=s;i<n+s;i++){sc(a[i]);}
#define read_arr_ll(a,s,n) for(ll i=s;i<n+s;i++){scll(a[i]);}
#define open(in,out) freopen(in,"r",stdin);freopen(out,"w",stdout);
#define err(a,s) cerr<<a<<s;
#define err_arr(a,s,n) for(ll i=s;i<n+s;i++){cerr<<a[i]<<" ";}cerr<<endl;
#define prtll(x) printf("%lld",x);
#define prt(x) printf("%d",x);
using namespace std;
const int N=2e3+10;
int pr[N],sz[N];
int get(int x){
    if(x == pr[x])return x;
    return  pr[x] = get(pr[x]);
}
bool join(int x , int y){
    x = get(x);
    y = get(y);
    if(x == y)return false;
    if(rand() & 1)swap(x , y);
    pr[x] = y;
    sz[y]+=sz[x];
    sz[x]=0;
    return true;
}
int n,q;
int main(){
loop(i,0,N-1){pr[i]=i;sz[i]=1;}
sc(n);sc(q);
while(q--){
 int u,v;
 sc(u);sc(v);
 join(u,v);
}
sc(q);
while(q--){
  int u,v;
  sc(u);sc(v);
  if(get(u)==get(v)){
    sz[get(u)]=-1;
  }
}
int ans=0;
loop(i,1,n){ans=max(ans,sz[get(i)]);}
printf("%d\n",ans);
}
/**
AB
#D
**/


//In the name of You, Our Dearest One:) LYH,M
#include <fstream>
#include <vector>
using namespace std;
const int Max=2e3+9;
vector <int> G[Max], V;
bool B[Max][Max], mark[Max];

void dfs (int sv)
{
    mark[sv]=1;
    V. push_back (sv);
    for (int i=0; i<G[sv].size(); i++) if (!mark[G[sv][i]])
        dfs (G[sv][i]);
}

int main()
{
    int n, m, mx=0, u, v;
    scanf ("%d%d", &n, &m);
    while (m--)
        scanf ("%d%d", &u, &v),
        G[u]. push_back (v),
        G[v]. push_back (u);
    scanf ("%d", &m);
    while (m--)
        scanf ("%d%d", &u, &v),
        B[u][v]=1, B[v][u]=1;
    for (int i=1; i<=n; i++) if (!mark[i])
    {
        dfs (i);
        for (int i=0; i<V. size(); i++)
            for (int j=i+1; j<V.size(); j++)
                if (B[V[i]][V[j]])
                    V. clear ();
        int sz=V. size();
        mx=max(mx, sz);
        V. clear ();
    }
    printf ("%d", max(mx, 1));
}


//In the name of You, Our Dearest One:) LYH,M
#include <fstream>
#include <vector>
using namespace std;
const int Max=2e3+9;
vector <int> G[Max], V;
bool B[Max][Max], mark[Max];

void dfs (int sv)
{
    mark[sv]=1;
    V. push_back (sv);
    for (int i=0; i<G[sv].size(); i++) if (!mark[G[sv][i]])
        dfs (G[sv][i]);
}

int main()
{
    int n, m, mx=0, u, v;
    scanf ("%d%d", &n, &m);
    while (m--)
        scanf ("%d%d", &u, &v),
        G[u]. push_back (v),
        G[v]. push_back (u);
    scanf ("%d", &m);
    while (m--)
        scanf ("%d%d", &u, &v),
        B[u][v]=1, B[v][u]=1;
    for (int i=1; i<=n; i++) if (!mark[i])
    {
        dfs (i);
        for (int i=0; i<V. size(); i++)
            for (int j=i+1; j<V.size(); j++)
                if (B[V[i]][V[j]])
                    V. clear ();
        int sz=V. size();
        mx=max(mx, sz);
        V. clear ();
    }
    printf ("%d", mx);
}


#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define MS0(a) memset(a,0,sizeof(a))

using namespace std;

typedef long long ll;
const int maxn=1000100;
const int INF=1e9+10;

int n;
int x[maxn];
int a,b;

int main()
{
    //freopen("in.txt","r",stdin);
    while(cin>>n){
        REP(i,1,n) scanf("%d",&x[i]);
        sort(x+1,x+n+1);
        n=unique(x+1,x+n+1)-(x+1);
        cin>>a>>b;
        int res=0;
        while(1){
            int na=a-1;
            REP(i,1,n){
                int t=a-a%x[i];
                if(t>=b) na=min(na,t);
            }
            res++;
            if(na==b) break;
            a=na;
        }
        cout<<res<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define MS0(a) memset(a,0,sizeof(a))

using namespace std;

typedef long long ll;
const int maxn=1000100;
const int INF=1e9+10;

int n;
int x[maxn];
int y[maxn],m;
int a,b;

int main()
{
    //freopen("in.txt","r",stdin);
    while(cin>>n){
        REP(i,1,n) scanf("%d",&x[i]);
        sort(x+1,x+n+1);
        n=unique(x+1,x+n+1)-(x+1);
        cin>>a>>b;
        int res=0;
        while(1){
            int na=a-1;
            REP(i,1,n){
                int t=a-a%x[i];
                if(t>=b) na=min(na,t);
            }
            res++;
            if(na==b) break;
            a=na;
            m=0;
            REP(i,1,n) if(a-a%x[i]>=b) y[++m]=x[i];
            REP(i,1,m) x[i]=y[i];
            n=m;
        }
        cout<<res<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

int const N = 1e5 + 20, MAX = 1e6 + 20, INF = 2e9;
int n, a, b, x[N], y[N], to[MAX], cnt, now, mn = INF;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i ++) cin >> y[i];
  sort(y, y + n);
  for (int i = 0; i < n; i ++) if (!i || y[i] != y[i - 1]) x[cnt ++] = y[i];
  n = cnt; cnt = 0;
  cin >> a >> b;

  for (int i = b + 1; i <= a; i ++) to[i - b] = i - 1;

  for (int i = 0; i < n; i ++)
    for (int j = b - (b % x[i]) + x[i]; j <= a; j += x[i])
      if (j - x[i] >= b) to[j - b] = min(to[j - b], j - x[i]);

  now = a;
  for (int i = 0; i < n; i ++) if (a - (a % x[i]) >= b) mn = min(mn, a - (a % x[i]));

  for (int i = a; i > b; i --){
    if (now == i){
      now = min(now - 1, mn);
      cnt ++;
    }

    mn = min(mn, to[i - b]);
  }

  if (now != b) cout << now << ' ' << b << endl;

  return cout << cnt << endl, 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

int const N = 1e5 + 20, MAX = 1e6 + 20, INF = 2e9;
int n, a, b, x[N], y[N], to[MAX], cnt, now, mn = INF;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i ++) cin >> y[i];
  sort(y, y + n);
  for (int i = 0; i < n; i ++) if (!i || y[i] != y[i - 1]) x[cnt ++] = y[i];
  n = cnt; cnt = 0;
  cin >> a >> b;

  for (int i = b + 1; i <= a; i ++) to[i - b] = i - 1;

  for (int i = 0; i < n; i ++)
    for (int j = b - (b % x[i]) + x[i]; j <= a; j += x[i])
      if (j - x[i] >= b) to[j - b] = min(to[j - b], j - x[i]);

  now = a;
  for (int i = 0; i < n; i ++) mn = min(mn, a - (a % x[i]));

  for (int i = a; i > b; i --){
    if (now == i){
      now = min(mn, now - 1);
      cnt ++;
    }

    mn = min(mn, to[i - b]);
  }

  if (now != b) assert(0);

  return cout << cnt << endl, 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

int const N = 1e5 + 20, MAX = 1e6 + 20, INF = 2e9;
int n, a, b, x[N], y[N], to[MAX], cnt, now, mn = INF;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i ++) cin >> y[i];
  sort(y, y + n);
  for (int i = 0; i < n; i ++) if (!i || y[i] != y[i - 1]) x[cnt ++] = y[i];
  n = cnt; cnt = 0;
  cin >> a >> b;

  for (int i = b + 1; i <= a; i ++) to[i - b] = i - 1;

  for (int i = 0; i < n; i ++)
    for (int j = b - (b % x[i]) + x[i]; j <= a; j += x[i])
      if (j - x[i] >= b) to[j - b] = min(to[j - b], j - x[i]);

  now = a;
  for (int i = 0; i < n; i ++) mn = min(mn, a - (a % x[i]));

  for (int i = a; i > b; i --){
    if (now == i){
      now = min(mn, now - 1);
      cnt ++;
    }

    mn = min(mn, to[i - b]);
  }

  return cout << cnt << endl, 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

int const N = 1e5 + 20, MAX = 1e6 + 20;
int n, a, b, x[N], cnt, now;
map <int, bool> mp;
set <pii> st;
vector <int> v[MAX];

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i ++){
    int y; cin >> y;
    if (!mp[y]) x[cnt ++] = y;
    mp[y] = 1;
  }
  n = cnt; cnt = 0;
  cin >> a >> b;

  for (int i = 0; i < n; i ++)
    for (int j = b - (b % x[i]) + x[i]; j <= a; j += x[i])
      v[j - b].push_back(x[i]);

  now = a;
  for (int i = 0; i < n; i ++) st.insert({a - (a % x[i]), x[i]});

  for (int i = a; i > b; i --){
    if (now == i){
      now = min((*st.begin()).first, now - 1);
      cnt ++;
    }

    for (auto y : v[i - b]){
      st.erase({i, y});
      if (i - y >= b) st.insert({i - y, y});
    }
  }

  return cout << cnt << endl, 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

int const N = 1e5 + 20, MAX = 1e6 + 20, INF = 2e9;
int n, a, b, x[N], y[N], to[MAX], cnt, now, mn = INF;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i ++) cin >> y[i];
  sort(y, y + n);
  for (int i = 0; i < n; i ++) if (!i || y[i] != y[i - 1]) x[cnt ++] = y[i];
  n = cnt; cnt = 0;
  cin >> a >> b;

  for (int i = b + 1; i <= a; i ++) to[i - b] = i - 1;

  for (int i = 0; i < n; i ++)
    for (int j = b - (b % x[i]) + x[i]; j <= a; j += x[i])
      if (j - x[i] >= b) to[j - b] = min(to[j - b], j - x[i]);

  now = a;
  for (int i = 0; i < n; i ++) mn = min(mn, a - (a % x[i]));

  for (int i = a; i > b; i --){
    if (now == i){
      now = min(mn, now - 1);
      cnt ++;
    }

    mn = min(mn, to[i - b]);
  }

  if (now != b) cout << now << ' ' << b << endl;

  return cout << cnt << endl, 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

int const N = 1e5 + 20, MAX = 1e6 + 20, INF = 2e9;
int n, a, b, x[N], y[N], cnt, now, mn = INF;
vector <int> v[MAX];

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i ++) cin >> y[i];
  sort(y, y + n);
  for (int i = 0; i < n; i ++) if (!i || y[i] != y[i - 1]) x[cnt ++] = y[i];
  n = cnt; cnt = 0;
  cin >> a >> b;

  for (int i = 0; i < n; i ++)
    for (int j = b - (b % x[i]) + x[i]; j <= a; j += x[i])
      v[j - b].push_back(x[i]);

  now = a;
  for (int i = 0; i < n; i ++) mn = min(mn, a - (a % x[i]));

  for (int i = a; i > b; i --){
    if (now == i){
      now = min(mn, now - 1);
      cnt ++;
    }

    for (auto y : v[i - b])
      if (i - y >= b) mn = min(mn, i - y);
  }

  return cout << cnt << endl, 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

int const N = 1e5 + 20, MAX = 1e6 + 10;
int n, a, b, x[N], cnt, now;
map <int, bool> mp;
set <pii> st;
vector <int> v[MAX];

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i ++){
    int y; cin >> y;
    if (!mp.count(y)) x[cnt ++] = y;
    mp[y] = 1;
  }
  n = cnt; cnt = 0;
  cin >> a >> b;

  for (int i = 0; i < n; i ++)
    for (int j = (b + x[i] - 1) / x[i] * x[i]; j <= a; j += x[i])
      v[j - b].push_back(x[i]);

  now = a;
  for (int i = 0; i < n; i ++) st.insert({a - (a % x[i]), x[i]});

  for (int i = a; i > b; i --){
    if (now == i){
      now = min((*st.begin()).first, now - 1);
      cnt ++;
    }

    for (auto y : v[i - b]){
      st.erase({i, y});
      st.insert({i - y, y});
    }
  }

  return cout << cnt << endl, 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

int const N = 1e5 + 20, MAX = 1e6 + 20;
int n, a, b, x[N], cnt, now;
map <int, bool> mp;
set <pii> st;
vector <int> v[MAX];

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i ++){
    int y; cin >> y;
    if (!mp.count(y)) x[cnt ++] = y;
    mp[y] = 1;
  }
  n = cnt; cnt = 0;
  cin >> a >> b;

  for (int i = 0; i < n; i ++)
    for (int j = b - (b % x[i]) + x[i]; j <= a; j += x[i])
      v[j - b].push_back(x[i]);

  now = a;
  for (int i = 0; i < n; i ++) st.insert({a - (a % x[i]), x[i]});

  for (int i = a; i > b; i --){
    if (now == i){
      now = min((*st.begin()).first, now - 1);
      cnt ++;
    }

    for (auto y : v[i - b]){
      st.erase({i, y});
      if (i - y >= b) st.insert({i - y, y});
    }
  }

  return cout << cnt << endl, 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

int const N = 1e5 + 20, MAX = 1e6 + 20, INF = 2e9;
int n, a, b, x[N], cnt, now, mn = INF;
map <int, bool> mp;
vector <int> v[MAX];

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i ++){
    int y; cin >> y;
    if (!mp[y]) x[cnt ++] = y;
    mp[y] = 1;
  }
  n = cnt; cnt = 0;
  cin >> a >> b;

  for (int i = 0; i < n; i ++)
    for (int j = b - (b % x[i]) + x[i]; j <= a; j += x[i])
      v[j - b].push_back(x[i]);

  now = a;
  for (int i = 0; i < n; i ++) mn = min(mn, a - (a % x[i]));

  for (int i = a; i > b; i --){
    if (now == i){
      now = min(mn, now - 1);
      cnt ++;
    }

    for (auto y : v[i - b])
      if (i - y >= b) mn = min(mn, i - y);
  }

  return cout << cnt << endl, 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

int const N = 1e5 + 20, MAX = 1e6 + 20, INF = 2e9;
int n, a, b, x[N], y[N], to[MAX], cnt, now, mn = INF;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i ++) cin >> y[i];
  sort(y, y + n);
  for (int i = 0; i < n; i ++) if (!i || y[i] != y[i - 1]) x[cnt ++] = y[i];
  n = cnt; cnt = 0;
  cin >> a >> b;

  for (int i = 0; i < n; i ++)
    for (int j = b - (b % x[i]) + x[i]; j <= a; j += x[i]){
      if (j - x[i] < b) continue;

      if (!to[j - b]) to[j - b] = j - x[i];
      else to[j - b] = min(to[j - b], j - x[i]);
    }

  now = a;
  for (int i = 0; i < n; i ++) mn = min(mn, a - (a % x[i]));

  for (int i = a; i > b; i --){
    if (now == i){
      now = min(mn, now - 1);
      cnt ++;
    }

    if (to[i - b]) mn = min(mn, to[i - b]);
  }

  return cout << cnt << endl, 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

int const N = 1e5 + 20, MAX = 1e6 + 20, INF = 2e9;
int n, a, b, x[N], y[N], to[MAX], cnt, now, mn = INF;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i ++) cin >> y[i];
  sort(y, y + n);
  for (int i = 0; i < n; i ++) if (!i || y[i] != y[i - 1]) x[cnt ++] = y[i];
  n = cnt; cnt = 0;
  cin >> a >> b;

  for (int i = b + 1; i <= a; i ++) to[i] = i - 1;

  for (int i = 0; i < n; i ++)
    for (int j = b - (b % x[i]) + x[i]; j <= a; j += x[i])
      if (j - x[i] >= b)  to[j - b] = min(to[j - b], j - x[i]);

  now = a;
  for (int i = 0; i < n; i ++) mn = min(mn, a - (a % x[i]));

  for (int i = a; i > b; i --){
    if (now == i){
      now = min(mn, now - 1);
      cnt ++;
    }

    mn = min(mn, to[i - b]);
  }

  return cout << cnt << endl, 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

int const N = 1e5 + 20, MAX = 1e6 + 20, INF = 2e9;
int n, a, b, x[N], y[N], to[MAX], cnt, now, mn = INF;

int32_t main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i ++) cin >> y[i];
  sort(y, y + n);
  for (int i = 0; i < n; i ++) if (!i || y[i] != y[i - 1]) x[cnt ++] = y[i];
  n = cnt; cnt = 0;
  cin >> a >> b;

  for (int i = b + 1; i <= a; i ++) to[i - b] = i - 1;

  for (int i = 0; i < n; i ++)
    for (int j = b - (b % x[i]) + x[i]; j <= a; j += x[i])
      if (j - x[i] >= b) to[j - b] = min(to[j - b], j - x[i]);

  now = a;
  for (int i = 0; i < n; i ++) mn = min(mn, a - (a % x[i]));

  for (int i = a; i > b; i --){
    if (now == i){
      now = min(mn, now - 1);
      cnt ++;
    }

    mn = min(mn, to[i - b]);
  }

  return cout << cnt << endl, 0;
}


#include <iostream>
#include <vector>
using namespace std;
const int NMax = 100005;
const int MaxDif = 1000005;
int A,B;
int N;
int X[NMax],V[NMax];
vector <int> Remainder[MaxDif];
void Read()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> X[i];
    cin >> A >> B;
}
int First(int x,int y)
{
    if(x % y == 0)
        return x;
    return x + y - x % y;
}

void buildRemainder()
{
    for(int i = 1; i <= N; i++)
    {
        for(int j = First(B, X[i]); j <= A; j += X[i])
            Remainder[j - B].push_back(i);
    }
}

void getAnswer()
{
    int ans = 0,step = 0,cnt;
    while(A > B)
    {
        cnt = 0;
        int sub, Max = 0;
        for(sub = A; cnt < N && sub >= B; sub--)
        {
            for(int j = 0; j < Remainder[sub - B].size(); j++)
                if(V[Remainder[sub - B][j]] == step)
                {
                    ++cnt;
                    Max = sub;
                    ++V[Remainder[sub - B][j]];
                }
        }
        if(sub==B-1)
        {
            if(Max == 0)
            {
                ans += A - B;
                A = B;
                continue;
            }
        }
        if(Max == A)
            --A;
        else
            A = Max;
        ++ans;
        ++step;
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    buildRemainder();
    getAnswer();
    return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
const int NMax = 100005;
const int MaxDif = 1000005;
int A, B, limit;
int N;
int X[NMax], V[NMax], X2[NMax];
bool Used[MaxDif];
map <int, int> M;
int Remainder[MaxDif];
void Read()
{
    int aux;
    cin >> N;
    aux = 0;
    for(int i = 1; i <= N; i++)
    {
        int val;
        cin >> val;
        if(M[val] == 0)
            X[++aux] = val,X2[aux] = val;
        M[val] = 1;
    }
    N = aux;
    cin >> A >> B;
    sort(X + 1, X + N + 1);
}
int First(int x,int y)
{
    if(x % y == 0)
        return x;
    return x + y - x % y;
}

void buildRemainder()
{
    for(int i = 1; i <= N; i++)
    {
        int aux = 0;
        for(int j = First(B, X[i]); j <= A; j += X[i])
            Remainder[j - B] = i, aux++;
        if(aux > 0)
            ++limit;
    }
}
inline int cmp(int x,int y)
{
    return First(B, x) <= First(B, y);
}
void getAnswer()
{
    sort(X2 + 1, X2 + N + 1, cmp);
    int ans = 0,step = 0,cnt,cnt2;

    while(A > B)
    {
        cnt = 0;
        int sub, Max = 0, cnt2 = 0, p = 1;
        for(sub = A; cnt < limit && sub >= B; sub--, cnt2++)
        {
            while(p <= N && X[p] <= cnt2)
            {
                if(V[p] == step)
                {
                    ++V[p];
                    cnt++;
                }
                ++p;
            }
            if(Remainder[sub - B] != 0 && V[Remainder[sub - B]] == step)
            {
                ++cnt;
                Max = sub;
                ++V[Remainder[sub - B]];
            }
        }
        if(limit == 0)
        {
            ans += A - B;
            A = B;
            continue;
        }
        if(sub == B - 1)
        {
            if(Max == 0)
            {
                ans += A - B;
                A = B;
                continue;
            }
        }
        if(Max == A)
            --A;
        else
            A = Max;
        ++ans;
        ++step;
        while(limit>0 && First(B, X2[limit]) > A)
            --limit;
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    buildRemainder();
    getAnswer();
    return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
/*ifstream cin("in.txt");
ofstream cout("out.txt");*/
const int NMax = 100005;
const int MaxDif = 1000005;
int A, B, limit;
int N;
int X[NMax], V[NMax], X2[NMax];
bool Used[MaxDif];
map <int, int> M;
int Remainder[MaxDif];
void Read()
{
    int aux;
    cin >> N;
    aux = 0;
    for(int i = 1; i <= N; i++)
    {
        int val;
        cin >> val;
        if(M[val] == 0)
            X[++aux] = val,X2[aux] = val;
        M[val] = 1;
    }
    N = aux;
    cin >> A >> B;
    sort(X + 1, X + N + 1);
}
int First(int x,int y)
{
    if(y == 0)
        return 0;
    if(x % y == 0)
        return x;
    return x + y - x % y;
}

void buildRemainder()
{
    for(int i = 1; i <= N; i++)
    {
        int aux = 0;
        for(int j = First(B, X[i]); j <= A; j += X[i])
            Remainder[j - B] = i, aux++;
        if(aux > 0)
            ++limit;
    }
}
inline int cmp(int x,int y)
{
    return First(B, x) <= First(B, y);
}
void getAnswer()
{
    sort(X2 + 1, X2 + N + 1, cmp);
    int ans = 0,step = 0,cnt,cnt2;

    while(A > B)
    {
        cnt = 0;
        int sub, Max = 0, cnt2 = 0, p = 1;
        for(sub = A; cnt < limit && sub >= B; sub--, cnt2++)
        {
            while(p <= N && X[p] <= cnt2)
            {
                if(V[p] == step)
                {
                    ++V[p];
                    cnt++;
                }
                ++p;
            }
            if(Remainder[sub - B] != 0 && V[Remainder[sub - B]] == step)
            {
                ++cnt;
                Max = sub;
                ++V[Remainder[sub - B]];
            }
        }
        if(limit == 0)
        {
            ans += A - B;
            A = B;
            continue;
        }
        if(sub == B - 1)
        {
            if(Max == 0)
            {
                ans += A - B;
                A = B;
                continue;
            }
        }
        if(Max == A)
            --A;
        else
            A = Max;
        ++ans;
        ++step;
        while(limit>0 && First(B, X2[limit]) > A)
            --limit;
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    buildRemainder();
    getAnswer();
    /*for(int i = 2; i <= 100001; i++)
        cout << i << " ";*/
    return 0;
}


#include <iostream>
#include <vector>
#include <map>
using namespace std;
const int NMax = 100005;
const int MaxDif = 1000005;
int A,B,limit;
int N;
int X[NMax],V[NMax];
bool Used[MaxDif];
map <int,int> M;
vector <int> Remainder[MaxDif];
void Read()
{
    int aux;
    cin >> N;
    aux = 0;
    for(int i = 1; i <= N; i++)
    {
        int val;
        cin >> val;
        if(M[val] == 0)
            X[++aux] = val;
        M[val] = 1;
    }
    N = aux;
    cin >> A >> B;
}
int First(int x,int y)
{
    if(x % y == 0)
        return x;
    return x + y - x % y;
}

void buildRemainder()
{
    for(int i = 1; i <= N; i++)
    {
        int aux = 0;
        for(int j = First(B, X[i]); j <= A; j += X[i])
            Remainder[j - B].push_back(i),aux++;
        if(aux > 0)
            ++limit;
    }
}

void getAnswer()
{
    int ans = 0,step = 0,cnt,cnt2;
    while(A > B)
    {
        cnt = 0;
        int sub, Max = 0,limit2 = limit;
        for(sub = A; cnt < limit && sub >= B; sub--)
        {
            cnt2 = 0;
            for(int j = 0; j < Remainder[sub - B].size(); j++)
                if(V[Remainder[sub - B][j]] == step)
                {
                    ++cnt;
                    ++cnt2;
                    if(sub - X[Remainder[sub - B][j]] < B)
                        --limit2;
                    Max = sub;
                    ++V[Remainder[sub - B][j]];
                }
        }
        if(limit == 0)
        {
            ans += A - B;
            A = B;
            continue;
        }
        limit = limit2 + cnt2;

        if(sub == B - 1)
        {
            if(Max == 0)
            {
                ans += A - B;
                A = B;
                continue;
            }
        }
        if(Max == A)
            --A;
        else
            A = Max;
        ++ans;
        ++step;
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    buildRemainder();
    getAnswer();
    return 0;
}


#include <iostream>
#include <vector>
#include <map>
using namespace std;
const int NMax = 100005;
const int MaxDif = 1000005;
int A,B,limit;
int N;
int X[NMax],V[NMax];
bool Used[MaxDif];
map <int,int> M;
vector <int> Remainder[MaxDif];
void Read()
{
    int aux;
    cin >> N;
    aux = 0;
    for(int i = 1; i <= N; i++)
    {
        int val;
        cin >> val;
        if(M[val] == 0)
            X[++aux] = val;
        M[val] = 1;
    }
    N = aux;
    cin >> A >> B;
}
int First(int x,int y)
{
    if(x % y == 0)
        return x;
    return x + y - x % y;
}

void buildRemainder()
{
    for(int i = 1; i <= N; i++)
    {
        int aux = 0;
        for(int j = First(B, X[i]); j <= A; j += X[i])
            Remainder[j - B].push_back(i),aux++;
        if(aux > 0)
            ++limit;
    }
}

void getAnswer()
{
    int ans = 0,step = 0,cnt;
    while(A > B)
    {
        cnt = 0;
        int sub, Max = 0,limit2 = limit;
        for(sub = A; cnt < limit && sub >= B; sub--)
        {
            for(int j = 0; j < Remainder[sub - B].size(); j++)
                if(V[Remainder[sub - B][j]] == step)
                {
                    ++cnt;
                    if(sub - X[Remainder[sub - B][j]] < B)
                        --limit2;
                    Max = sub;
                    ++V[Remainder[sub - B][j]];
                }
        }
        limit = limit2;
        if(sub == B - 1)
        {
            if(Max == 0)
            {
                ans += A - B;
                A = B;
                continue;
            }
        }
        if(Max == A)
            --A;
        else
            A = Max;
        ++ans;
        ++step;
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    buildRemainder();
    getAnswer();
    return 0;
}


#include <iostream>
#include <vector>
#include <map>
using namespace std;
const int NMax = 100005;
const int MaxDif = 1000005;
int A,B;
int N;
int X[NMax],V[NMax];
bool Used[MaxDif];
map <int,int> M;
vector <int> Remainder[MaxDif];
void Read()
{
    int aux;
    cin >> N;
    aux = 0;
    for(int i = 1; i <= N; i++)
    {
        int val;
        cin >> val;
        if(M[val] == 0)
            X[++aux] = val;
        M[val] = 1;
    }
    N = aux;
    cin >> A >> B;
}
int First(int x,int y)
{
    if(x % y == 0)
        return x;
    return x + y - x % y;
}

void buildRemainder()
{
    for(int i = 1; i <= N; i++)
    {
        for(int j = First(B, X[i]); j <= A; j += X[i])
            Remainder[j - B].push_back(i);
    }
}

void getAnswer()
{
    int ans = 0,step = 0,cnt;
    while(A > B)
    {
        cnt = 0;
        int sub, Max = 0;
        for(sub = A; cnt < N && sub >= B; sub--)
        {
            for(int j = 0; j < Remainder[sub - B].size(); j++)
                if(V[Remainder[sub - B][j]] == step)
                {
                    ++cnt;
                    Max = sub;
                    ++V[Remainder[sub - B][j]];
                }
        }
        if(sub == B - 1)
        {
            if(Max == 0)
            {
                ans += A - B;
                A = B;
                continue;
            }
        }
        if(Max == A)
            --A;
        else
            A = Max;
        ++ans;
        ++step;
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    buildRemainder();
    getAnswer();
    return 0;
}


#include <iostream>
#include <vector>
#include <map>
using namespace std;
const int NMax = 100005;
const int MaxDif = 1000005;
int A,B,limit;
int N;
int X[NMax],V[NMax];
bool Used[MaxDif];
map <int,int> M;
vector <int> Remainder[MaxDif];
void Read()
{
    int aux;
    cin >> N;
    aux = 0;
    for(int i = 1; i <= N; i++)
    {
        int val;
        cin >> val;
        if(M[val] == 0)
            X[++aux] = val;
        M[val] = 1;
    }
    N = aux;
    cin >> A >> B;
}
int First(int x,int y)
{
    if(x % y == 0)
        return x;
    return x + y - x % y;
}

void buildRemainder()
{
    for(int i = 1; i <= N; i++)
    {
        int aux = 0;
        for(int j = First(B, X[i]); j <= A; j += X[i])
            Remainder[j - B].push_back(i),aux++;
        if(aux > 0)
            ++limit;
    }
}

void getAnswer()
{
    int ans = 0,step = 0,cnt,cnt2;
    while(A > B)
    {
        cnt = 0;
        int sub, Max = 0,limit2 = limit;
        for(sub = A; cnt < limit && sub >= B; sub--)
        {
            cnt2 = 0;
            for(int j = 0; j < Remainder[sub - B].size(); j++)
                if(V[Remainder[sub - B][j]] == step)
                {
                    ++cnt;
                    if(sub - X[Remainder[sub - B][j]] < B)
                        --limit2,cnt2++;
                    Max = sub;
                    ++V[Remainder[sub - B][j]];
                }
        }
        if(limit == 0)
        {
            ans += A - B;
            A = B;
            continue;
        }
        limit = limit2 + cnt2;
//p
        if(sub == B - 1)
        {
            if(Max == 0)
            {
                ans += A - B;
                A = B;
                continue;
            }
        }
        if(Max == A)
            --A;
        else
            A = Max;
        ++ans;
        ++step;
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    buildRemainder();
    getAnswer();
    return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;
const int NMax = 100005;
const int MaxDif = 1000005;
int A,B,limit;
int N;
int X[NMax],V[NMax],Link[MaxDif],Aux[NMax];
bool Used[MaxDif];
map <int,int> M;
set <pair <int,int> > S;
vector <int> Remainder[MaxDif];
void Read()
{
    int aux;
    cin >> N;
    aux = 0;
    for(int i = 1; i <= N; i++)
    {
        int val;
        cin >> val;
        if(M[val] == 0)
            X[++aux] = val;
        M[val] = 1;
    }
    N = aux;
    cin >> A >> B;
}
int First(int x,int y)
{
    if(x % y == 0)
        return x;
    return x + y - x % y;
}

void buildRemainder()
{
    for(int i = 1; i <= N; i++)
    {
        int aux = 0;
        for(int j = First(B, X[i]); j <= A; j += X[i])
            Remainder[j - B].push_back(i),aux++;
        if(aux > 0)
            ++limit;
    }
}
void buildLink()
{
    for(int i = 1; i <= N; i++)
        if(A - A % X[i] >= B)
            S.insert(make_pair(A - A % X[i],X[i]));
    Aux[0] = 0;
    Link[A - B] = min(A - 1, S.begin() -> first);
    while(S.size() > 0 && prev(S.end()) -> first == A)
    {
        Aux[++Aux[0]] = prev(S.end()) -> second;
        S.erase(prev(S.end()));
    }
    for(int j = 1; j <= Aux[0]; j++)
        if(A - Aux[j] >= B)
            S.insert(make_pair(A - Aux[j], Aux[j]));
    for(int i = A - 1; i >= B; i--)
    {
        Link[i - B] = min(i - 1, S.begin() -> first);
        Aux[0] = 0;
        while(S.size() > 0 && prev(S.end()) -> first == i)
        {
            Aux[++Aux[0]] = prev(S.end()) -> second;
            S.erase(prev(S.end()));
        }
        for(int j = 1; j <= Aux[0]; j++)
            if(i - Aux[j] >= B)
                S.insert(make_pair(i - Aux[j],Aux[j]));
    }

}
void getAnswer()
{
    int ans = 0,step = 0,cnt,cnt2;
    while(A > B)
    {
        A = Link[A - B];
        ++ans;
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    buildLink();
    getAnswer();
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
const int NMax = 100005;
const int MaxDif = 1000005;
int A,B;
int N;
int X[NMax],V[NMax];
bool Used[MaxDif];
vector <int> Remainder[MaxDif];
void Read()
{
    int aux;
    cin >> N;
    aux = 0;
    for(int i = 1; i <= N; i++)
    {
        int val;
        cin >> val;
        if(Used[val] == 0)
            X[++aux] = val;
        Used[val] = 1;
    }
    N = aux;
    cin >> A >> B;
}
int First(int x,int y)
{
    if(x % y == 0)
        return x;
    return x + y - x % y;
}

void buildRemainder()
{
    for(int i = 1; i <= N; i++)
    {
        for(int j = First(B, X[i]); j <= A; j += X[i])
            Remainder[j - B].push_back(i);
    }
}

void getAnswer()
{
    int ans = 0,step = 0,cnt;
    while(A > B)
    {
        cnt = 0;
        int sub, Max = 0;
        for(sub = A; cnt < N && sub >= B; sub--)
        {
            for(int j = 0; j < Remainder[sub - B].size(); j++)
                if(V[Remainder[sub - B][j]] == step)
                {
                    ++cnt;
                    Max = sub;
                    ++V[Remainder[sub - B][j]];
                }
        }
        if(sub==B-1)
        {
            if(Max == 0)
            {
                ans += A - B;
                A = B;
                continue;
            }
        }
        if(Max == A)
            --A;
        else
            A = Max;
        ++ans;
        ++step;
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    buildRemainder();
    getAnswer();
    return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
const int NMax = 100005;
const int MaxDif = 1000005;
int A, B, limit;
int N;
int X[NMax], V[NMax], X2[NMax];
bool Used[MaxDif];
map <int, int> M;
int Remainder[MaxDif];
void Read()
{
    int aux;
    cin >> N;
    aux = 0;
    for(int i = 1; i <= N; i++)
    {
        int val;
        cin >> val;
        if(M[val] == 0)
            X[++aux] = val,X2[aux] = val;
        M[val] = 1;
    }
    N = aux;
    cin >> A >> B;
    sort(X + 1, X + N + 1);
}
int First(int x,int y)
{
    if(x % y == 0)
        return x;
    return x + y - x % y;
}

void buildRemainder()
{
    for(int i = 1; i <= N; i++)
    {
        int aux = 0;
        for(int j = First(B, X[i]); j <= A; j += X[i])
            Remainder[j - B] = i, aux++;
        if(aux > 0)
            ++limit;
    }
}
inline int cmp(int x,int y)
{
    return First(B, x) <= First(B, y);
}
void getAnswer()
{
    sort(X2 + 1, X2 + N + 1, cmp);
    int ans = 0,step = 0,cnt,cnt2;

    while(A > B)
    {
        cnt = 0;
        int sub, Max = 0, cnt2 = 0, p = 1;
        for(sub = A; cnt < limit && sub >= B; sub--, cnt2++)
        {
            while(p <= limit && X[p] <= cnt2)
            {
                if(V[p] == step)
                {
                    ++V[p];
                    cnt++;
                }
                ++p;
            }
            if(Remainder[sub - B] != 0 && V[Remainder[sub - B]] == step)
            {
                ++cnt;
                Max = sub;
                ++V[Remainder[sub - B]];
            }
        }
        if(limit == 0)
        {
            ans += A - B;
            A = B;
            continue;
        }
        if(sub == B - 1)
        {
            if(Max == 0)
            {
                ans += A - B;
                A = B;
                continue;
            }
        }
        if(Max == A)
            --A;
        else
            A = Max;
        ++ans;
        ++step;
        while(limit>0 && First(B, X2[limit]) > A)
            --limit;
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    buildRemainder();
    getAnswer();
    return 0;
}


#include <iostream>
#include <vector>
#include <map>
using namespace std;
const int NMax = 100005;
const int MaxDif = 1000005;
int A,B,limit;
int N;
int X[NMax],V[NMax];
bool Used[MaxDif];
map <int,int> M;
vector <int> Remainder[MaxDif];
void Read()
{
    int aux;
    cin >> N;
    aux = 0;
    for(int i = 1; i <= N; i++)
    {
        int val;
        cin >> val;
        if(M[val] == 0)
            X[++aux] = val;
        M[val] = 1;
    }
    N = aux;
    cin >> A >> B;
}
int First(int x,int y)
{
    if(x % y == 0)
        return x;
    return x + y - x % y;
}

void buildRemainder()
{
    for(int i = 1; i <= N; i++)
    {
        int aux = 0;
        for(int j = First(B, X[i]); j <= A; j += X[i])
            Remainder[j - B].push_back(i),aux++;
        if(aux > 0)
            ++limit;
    }
}

void getAnswer()
{
    int ans = 0,step = 0,cnt,cnt2;
    while(A > B)
    {
        cnt = 0;
        int sub, Max = 0,limit2 = limit;
        for(sub = A; cnt < limit && sub >= B; sub--)
        {
            cnt2 = 0;
            for(int j = 0; j < Remainder[sub - B].size(); j++)
                if(V[Remainder[sub - B][j]] == step)
                {
                    ++cnt;
                    ++cnt2;
                    if(sub - X[Remainder[sub - B][j]] < B)
                        --limit2;
                    Max = sub;
                    ++V[Remainder[sub - B][j]];
                }
        }
        if(limit == 0)
        {
            ans += A - B;
            A = B;
            continue;
        }
        limit = limit2 + cnt2;
//p
        if(sub == B - 1)
        {
            if(Max == 0)
            {
                ans += A - B;
                A = B;
                continue;
            }
        }
        if(Max == A)
            --A;
        else
            A = Max;
        ++ans;
        ++step;
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    buildRemainder();
    getAnswer();
    return 0;
}


#include <iostream>
#include <vector>
#include <map>
using namespace std;
const int NMax = 100005;
const int MaxDif = 1000005;
int A,B,limit;
int N;
int X[NMax],V[NMax];
bool Used[MaxDif];
map <int,int> M;
vector <int> Remainder[MaxDif];
void Read()
{
    int aux;
    cin >> N;
    aux = 0;
    for(int i = 1; i <= N; i++)
    {
        int val;
        cin >> val;
        if(M[val] == 0)
            X[++aux] = val;
        M[val] = 1;
    }
    N = aux;
    cin >> A >> B;
}
int First(int x,int y)
{
    if(x % y == 0)
        return x;
    return x + y - x % y;
}

void buildRemainder()
{
    for(int i = 1; i <= N; i++)
    {
        int aux = 0;
        for(int j = First(B, X[i]); j <= A; j += X[i])
            Remainder[j - B].push_back(i),aux++;
        if(aux > 0)
            ++limit;
    }
}

void getAnswer()
{
    int ans = 0,step = 0,cnt,cnt2;
    while(A > B)
    {
        cnt = 0;
        int sub, Max = 0,limit2 = limit;
        for(sub = A; cnt < limit && sub >= B; sub--)
        {
            cnt2 = 0;
            for(int j = 0; j < Remainder[sub - B].size(); j++)
                if(V[Remainder[sub - B][j]] == step)
                {
                    ++cnt;
                    if(sub - X[Remainder[sub - B][j]] < B)
                        --limit2,cnt2++;
                    Max = sub;
                    ++V[Remainder[sub - B][j]];
                }
        }
        if(limit == 0)
        {
            ans += A - B;
            A = B;
            continue;
        }
        limit = limit2 + cnt2;
//pa
        if(sub == B - 1)
        {
            if(Max == 0)
            {
                ans += A - B;
                A = B;
                continue;
            }
        }
        if(Max == A)
            --A;
        else
            A = Max;
        ++ans;
        ++step;
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    buildRemainder();
    getAnswer();
    return 0;
}


#include <iostream>
#include <vector>
#include <map>
using namespace std;
const int NMax = 100005;
const int MaxDif = 1000005;
int A,B,limit;
int N;
int X[NMax],V[NMax];
bool Used[MaxDif];
map <int,int> M;
vector <int> Remainder[MaxDif];
void Read()
{
    int aux;
    cin >> N;
    aux = 0;
    for(int i = 1; i <= N; i++)
    {
        int val;
        cin >> val;
        if(M[val] == 0)
            X[++aux] = val;
        M[val] = 1;
    }
    N = aux;
    cin >> A >> B;
}
int First(int x,int y)
{
    if(x % y == 0)
        return x;
    return x + y - x % y;
}

void buildRemainder()
{
    for(int i = 1; i <= N; i++)
    {
        int aux = 0;
        for(int j = First(B, X[i]); j <= A; j += X[i])
            Remainder[j - B].push_back(i),aux++;
        if(aux > 0)
            ++limit;
    }
}

void getAnswer()
{
    int ans = 0,step = 0,cnt,cnt2;
    while(A > B)
    {
        cnt = 0;
        int sub, Max = 0,limit2 = limit;
        for(sub = A; cnt < limit && sub >= B; sub--)
        {
            cnt2 = 0;
            for(int j = 0; j < Remainder[sub - B].size(); j++)
                if(V[Remainder[sub - B][j]] == step)
                {
                    ++cnt;
                    if(sub - X[Remainder[sub - B][j]] < B)
                        --limit2,cnt2++;
                    Max = sub;
                    ++V[Remainder[sub - B][j]];
                }
        }
        if(limit == 0)
        {
            ans += A - B;
            A = B;
            continue;
        }
        limit = limit2 + cnt2;
//pap
        if(sub == B - 1)
        {
            if(Max == 0)
            {
                ans += A - B;
                A = B;
                continue;
            }
        }
        if(Max == A)
            --A;
        else
            A = Max;
        ++ans;
        ++step;
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    buildRemainder();
    getAnswer();
    return 0;
}


#include <iostream>
#include <vector>
#include <map>
using namespace std;
const int NMax = 100005;
const int MaxDif = 1000005;
int A,B,limit;
int N;
int X[NMax],V[NMax];
bool Used[MaxDif];
map <int,int> M;
vector <int> Remainder[MaxDif];
void Read()
{
    int aux;
    cin >> N;
    aux = 0;
    for(int i = 1; i <= N; i++)
    {
        int val;
        cin >> val;
        if(M[val] == 0)
            X[++aux] = val;
        M[val] = 1;
    }
    N = aux;
    cin >> A >> B;
}
int First(int x,int y)
{
    if(x % y == 0)
        return x;
    return x + y - x % y;
}

void buildRemainder()
{
    for(int i = 1; i <= N; i++)
    {
        int aux = 0;
        for(int j = First(B, X[i]); j <= A; j += X[i])
            Remainder[j - B].push_back(i),aux++;
        if(aux > 0)
            ++limit;
    }
}

void getAnswer()
{
    int ans = 0,step = 0,cnt,cnt2;
    while(A > B)
    {
        cnt = 0;
        int sub, Max = 0,limit2 = limit;
        for(sub = A; cnt < limit && sub >= B; sub--)
        {
            cnt2 = 0;
            for(int j = 0; j < Remainder[sub - B].size(); j++)
                if(V[Remainder[sub - B][j]] == step)
                {
                    ++cnt;
                    if(sub - X[Remainder[sub - B][j]] < B)
                        --limit2,cnt2++;
                    Max = sub;
                    ++V[Remainder[sub - B][j]];
                }
        }
        if(limit == 0)
        {
            ans += A - B;
            A = B;
            continue;
        }
        limit = limit2 + cnt2;
//pap
        /*if(sub == B - 1)
        {
            if(Max == 0)
            {
                ans += A - B;
                A = B;
                continue;
            }
        }*/
        if(Max == A)
            --A;
        else
            A = Max;
        ++ans;
        ++step;
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    buildRemainder();
    getAnswer();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int main(){
	int n;
	cin >> n;
	vector<int> arr(n);
	for(int i = 0; i < n; ++i)
		scanf("%d",&arr[i]);
	sort(arr.begin(),arr.end());
	arr.resize(unique(arr.begin(),arr.end())-arr.begin());
	n = arr.size();
	int a,b;
	cin >> a >> b;
	int moves = 0;
	while(a>b){
		vector<int> nxt;
		++moves;
//		cout << a << '\n';
		int c = a-1;
		for(int i = 0; i < n; ++i){
			if(a-a%arr[i]>=b){
				c = min(c,a-a%arr[i]);
				nxt.push_back(arr[i]);
			}
		}
		a = c;
		arr = nxt;
	}
	cout << moves << '\n';
}


#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int main(){
	int n;
	cin >> n;
	vector<int> arr(n);
	for(int i = 0; i < n; ++i)
		scanf("%d",&arr[i]);
	sort(arr.begin(),arr.end());
	arr.resize(unique(arr.begin(),arr.end())-arr.begin());
	n = arr.size();
	int a,b;
	cin >> a >> b;
	int moves = 0;
	while(a>b){
		++moves;
//		cout << a << '\n';
		int c = a-1;
		for(int i = 0; i < n; ++i){
			if(a-a%arr[i]>=b){
				c = min(c,a-a%arr[i]);
			}
		}
		a = c;
	}
	cout << moves << '\n';
}


#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
bool flag = false;
int main(){
	int n;
	cin >> n;
	vector<int> arr(n);
	for(int i = 0; i < n; ++i)
		scanf("%d",&arr[i]);
	if(arr[0]==753088) flag = true;
	sort(arr.begin(),arr.end());
	arr.resize(unique(arr.begin(),arr.end())-arr.begin());
	n = arr.size();
	int a,b;
	cin >> a >> b;
	int moves = 0;
	while(a>b){
//		if(flag) cout << a << ' ' << b << ' '<<
		vector<int> nxt;
		++moves;
		int c = a-1;
		for(int i = 0; i < n; ++i){
			if(a-a%arr[i]>=b){
				c = min(c,a-a%arr[i]);
				nxt.push_back(arr[i]);
			}
		}
		a = c;
		arr = nxt;
		n = arr.size();
	}
	cout << moves << '\n';
}


//  main.cpp
//  Practice

//  Copyright (c) 2014 Tapan. All rights reserved.
//

#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<deque>
#include<map>
#include<set>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
#define ll long long
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%I64d",&x)
#define prl(x) printf("%I64d",x)
#define pri(x) printf("%d\n",x)
#define prs(x) printf("%s\n",x)
typedef pair<int, int> ii;
typedef pair<ll, ll> iil;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
#define vl vector<ll>
#define vi vector<int>
#define vii vector<ii>
#define vvl vector< vl >
#define vvi vector< vi >
#define vvii vector< vii >
#define pb push_back
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define max_int_value 2147483647
#define max_long_value 9223372036854775807
#define mod 1000000007
#define pb push_back

const int  maxn  = 100001;

const int INF  = 1000000008;

int x[maxn];
inline void solve(void){
        int n;
        cin >> n;
        for(int  i = 0;i<n;i++)  scanf("%d",&x[i]);
        int id = 1;
        for(int i = 1; i < n; i ++)
        if(x[i] != x[i - 1])
        x[id ++] = x[i];
        n = id;
        int a , b;
        int res = 0;
        scanf("%d%d" , &a , &b);
        while(a > b){
            int max_sub  = 1;
            for(int i = 0; i < n; i++){
                if( a - a%x[i] >= b) max_sub = max(max_sub , a%x[i]);
            }

        a-= max_sub;
        res++;
         while (n > 1 && (a - a%x[n-1] < b)) n--;
        }
         cout << res;

}
int main(int argc, const char * argv[]){
    solve();
    return 0;
}


//  main.cpp
//  Practice

//  Copyright (c) 2014 Tapan. All rights reserved.
//

#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<deque>
#include<map>
#include<set>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
#define ll long long
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%I64d",&x)
#define prl(x) printf("%I64d",x)
#define pri(x) printf("%d\n",x)
#define prs(x) printf("%s\n",x)
typedef pair<int, int> ii;
typedef pair<ll, ll> iil;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
#define vl vector<ll>
#define vi vector<int>
#define vii vector<ii>
#define vvl vector< vl >
#define vvi vector< vi >
#define vvii vector< vii >
#define pb push_back
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define max_int_value 2147483647
#define max_long_value 9223372036854775807
#define mod 1000000007
#define pb push_back

const int  maxn  = 100004;

const int INF  = 1000000008;

int x[maxn];
inline void solve(void){
        int n;
        cin >> n;
        for(int  i = 0;i<n;i++)  cin >> x[i];
        n = unique(x,x+n) - x;
        int a , b;
        int res = 0;
        cin >> a >> b;
        while(a > b){
            int max_sub  = 1;
            for(int i = 0; i < n; i++){
                if( a - a%x[i] >= b) max_sub = max(max_sub , a%x[i]);
            }

        a-= max_sub;
        res++;
         while (n > 1 && a - a%x[n-1] < b) n--;
        }
         cout << res;

}
int main(int argc, const char * argv[]){
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}


//  main.cpp
//  Practice

//  Copyright (c) 2014 Tapan. All rights reserved.
//

#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<deque>
#include<map>
#include<set>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
#define ll long long
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%I64d",&x)
#define prl(x) printf("%I64d",x)
#define pri(x) printf("%d\n",x)
#define prs(x) printf("%s\n",x)
typedef pair<int, int> ii;
typedef pair<ll, ll> iil;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
#define vl vector<ll>
#define vi vector<int>
#define vii vector<ii>
#define vvl vector< vl >
#define vvi vector< vi >
#define vvii vector< vii >
#define pb push_back
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define max_int_value 2147483647
#define max_long_value 9223372036854775807
#define mod 1000000007
#define pb push_back

const int  maxn  = 100001;

const int INF  = 1000000008;

int x[maxn];
inline void solve(void){
        int n;
        cin >> n;
        for(int  i = 0;i<n;i++)  scanf("%d",&x[i]);
        int id = 1;
        for(int i = 1; i < n; i ++)
        if(x[i] != x[i - 1])
        x[id ++] = x[i];
        n = id;
        int a , b;
        int res = 0;
        scanf("%d%d" , &a , &b);
        while(a > b){
            int max_sub  = 1;
            for(int i = n-1; i >=0;i--){
                if( a - a%x[i] >= b) max_sub = max(max_sub , a%x[i]);
            }

        a-= max_sub;
        res++;
         while (n > 1 && (a - a%x[n-1] < b)) n--;
        }
         printf("%d\n", res);

}
int main(int argc, const char * argv[]){
    solve();
    return 0;
}


//  main.cpp
//  Practice

//  Copyright (c) 2014 Tapan. All rights reserved.
//

#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<deque>
#include<map>
#include<set>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
#define ll long long
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%I64d",&x)
#define prl(x) printf("%I64d",x)
#define pri(x) printf("%d\n",x)
#define prs(x) printf("%s\n",x)
typedef pair<int, int> ii;
typedef pair<ll, ll> iil;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
#define vl vector<ll>
#define vi vector<int>
#define vii vector<ii>
#define vvl vector< vl >
#define vvi vector< vi >
#define vvii vector< vii >
#define pb push_back
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define max_int_value 2147483647
#define max_long_value 9223372036854775807
#define mod 1000000007
#define pb push_back

const int  maxn  = 100001;

const int INF  = 1000000008;

int x[maxn];
inline void solve(void){
        int n;
        cin >> n;
        for(int  i = 0;i<n;i++)  scanf("%d",&x[i]);
            sort(x , x+n);
        int id = 1;
        for(int i = 1; i < n; i ++)
        if(x[i] != x[i - 1])
        x[id ++] = x[i];
        n = id;
        int a , b;
        int res = 0;
        scanf("%d%d" , &a , &b);
        while(a > b){
            int max_sub  = 1;
            for(int i = n-1; i >=0;i--){
                if( a - a%x[i] >= b) max_sub = max(max_sub , a%x[i]);
            }

        a-= max_sub;
        res++;
         while (n > 1 && (a - a%x[n-1] < b)) n--;
        }
         printf("%d\n", res);

}
int main(int argc, const char * argv[]){
    solve();
    return 0;
}


//  main.cpp
//  Practice

//  Copyright (c) 2014 Tapan. All rights reserved.
//

#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<deque>
#include<map>
#include<set>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
#define ll long long
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%I64d",&x)
#define prl(x) printf("%I64d",x)
#define pri(x) printf("%d\n",x)
#define prs(x) printf("%s\n",x)
typedef pair<int, int> ii;
typedef pair<ll, ll> iil;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
#define vl vector<ll>
#define vi vector<int>
#define vii vector<ii>
#define vvl vector< vl >
#define vvi vector< vi >
#define vvii vector< vii >
#define pb push_back
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define max_int_value 2147483647
#define max_long_value 9223372036854775807
#define mod 1000000007
#define pb push_back

const int  maxn  = 100001;

const int INF  = 1000000008;

int x[maxn];
inline void solve(void){
        int n;
        cin >> n;
        for(int  i = 0;i<n;i++)  scanf("%d",&x[i]);
        n = unique(x,x+n) - x;
        int a , b;
        int res = 0;
        scanf("%d%d" , &a , &b);
        while(a > b){
            int max_sub  = 1;
            for(int i = 0; i < n; i++){
                if( a - a%x[i] >= b) max_sub = max(max_sub , a%x[i]);
            }

        a-= max_sub;
        res++;
         while (n > 1 && (a - a%x[n-1] < b)) n--;
        }
         cout << res;

}
int main(int argc, const char * argv[]){
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int w,ans;
int x[100005],a,b;
int main()
{
	cin>>w;
	for(int i=1;i<=w;i++)
	{
		cin>>x[i];
	}
	cin>>a>>b;
	sort(x+1,x+w+1);
	int n=unique(x+1,x+w+1)-(x+1);
	while(a>b)
	{
		int now=a-1;
		for(int i=n;i>=1;i--)
		{
			if(a-a%x[i]>=b)
				now=min(now,a-a%x[i]);
		}
		ans++;
		a=now;
		while(n)
		{
			if(a-a%x[n]<b) n--;
			else break;
		}
	}
	cout<<ans;
	return 0;
}


#include<cstdio>
#include<cmath>
const int N=1e5+10,M=1e6+10;
int mn[M<<2];
inline int min(int a,int b){return a<b?a:b;}
inline void pushup(int rt){mn[rt]=min(mn[rt<<1],mn[rt<<1|1]);}
void update(int rt,int l,int r,int p,int x)
{
    if(l==r){mn[rt]=x;return;}
    int m=(l+r)>>1;
    if(p<=m)update(rt<<1,l,m,p,x);
    else update(rt<<1|1,m+1,r,p,x);
    pushup(rt);
}
int query(int rt,int l,int r,int ql,int qr)
{
    if(ql<=l&&r<=qr)return mn[rt];
    int m=(l+r)>>1,lans=1e9,rans=1e9;
    if(ql<=m)lans=query(rt<<1,l,m,ql,qr);
    if(qr>m)rans=query(rt<<1|1,m+1,r,ql,qr);
    return min(lans,rans);
}
int n,x[N],a,b,f[M],g[M];
int main()
{
    int i,j,m;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    scanf("%d",&x[i]);
    scanf("%d%d",&a,&b);
    a^=b^=a^=b;
    m=b-a+1;
    for(i=1;i<=n;i++)
    for(j=ceil(a*1.0/x[i])*x[i];j<=b;j+=x[i])
    if(g[j-a+1]<x[i])g[j-a+1]=x[i];
    for(i=1;i<=m;i++)
    if(g[i])g[i]--;else g[i]++;
    for(i=m-1;i;i--)
    f[i]=query(1,1,m,i+1,min(i+g[i],m))+1,
    update(1,1,m,i,f[i]);
    printf("%d\n",f[1]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int x[111111], r[1111111];

int main() {
	int n, a, b;
	scanf("%d", &n);
	for (int i=0; i<n; ++i) scanf("%d", x+i);
	sort(x, x+n);
	n = unique(x, x+n) - x;
	scanf("%d%d", &b, &a);
	fill(r, r+1111111, 1);
	for (int i=0; i<n; ++i) {
		for (int j=(a+x[i-1])/x[i]*x[i]; j<=b; j+=x[i]) {
			r[j-a] = max(r[j-a], x[i]-1);
		}
	}
	int r1 = a, r2 = a - 1, step = 0;
	for (int i=a; r1<b; ++i) {
		if (i + r[i-a] > r1) {
			if (i > r2) {
				++step;
				r2 = r1;
			}
			r1 = i + r[i-a];
		}
	}
	printf("%d\n", step);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int x[111111], r[111111];

int main() {
	int n, a, b;
	scanf("%d", &n);
	for (int i=0; i<n; ++i) scanf("%d", x+i);
	sort(x, x+n);
	n = unique(x, x+n) - x;
	scanf("%d%d", &b, &a);
	fill(r, r+111111, 1);
	for (int i=0; i<n; ++i) {
		for (int j=(a+x[i-1])/x[i]*x[i]; j<=b; j+=x[i]) {
			r[j-a] = max(r[j-a], x[i]-1);
		}
	}
	int r1 = a, r2 = a - 1, step = 0;
	for (int i=a; r1<b; ++i) {
		if (i + r[i-a] > r1) {
			if (i > r2) {
				++step;
				r2 = r1;
			}
			r1 = i + r[i-a];
		}
	}
	printf("%d\n", step);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int x[111111], r[1111111];

int main() {
	int n, a, b;
	scanf("%d", &n);
	for (int i=0; i<n; ++i) scanf("%d", x+i);
	sort(x, x+n);
	n = unique(x, x+n) - x;
	scanf("%d%d", &b, &a);
	fill(r, r+1111111, 1);
	for (int i=0; i<n; ++i) {
		for (int j=(a+x[i]-1)/x[i]*x[i]; j<=b; j+=x[i]) {
			r[j-a] = max(r[j-a], x[i]-1);
		}
	}
	int r1 = a, r2 = a - 1, step = 0;
	for (int i=a; r1<b; ++i) {
		if (i + r[i-a] > r1) {
			if (i > r2) {
				++step;
				r2 = r1;
			}
			r1 = i + r[i-a];
		}
	}
	printf("%d\n", step);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int x[111111], r[1111111];

int main() {
	int n, a, b;
	scanf("%d", &n);
	for (int i=0; i<n; ++i) scanf("%d", x+i);
	sort(x, x+n);
	n = unique(x, x+n) - x;
	scanf("%d%d", &b, &a);
	fill(r, r+111111, 1);
	for (int i=0; i<n; ++i) {
		for (int j=(a+x[i-1])/x[i]*x[i]; j<=b; j+=x[i]) {
			r[j-a] = max(r[j-a], x[i]-1);
		}
	}
	int r1 = a, r2 = a - 1, step = 0;
	for (int i=a; r1<b; ++i) {
		if (i + r[i-a] > r1) {
			if (i > r2) {
				++step;
				r2 = r1;
			}
			r1 = i + r[i-a];
		}
	}
	printf("%d\n", step);
	return 0;
}


/*
 * if you are interested in the reference code here,
 * see https://github.com/georeth/OJLIBS for more information
 *
 * Solution Author : Georeth Chow <georeth2010@gmail.com>
 */
#include <cstdio>
#include <cmath>
#include <cstring>      // memset
#include <cstdlib>      // malloc
#include <cstdint>      // int64_t
#include <cinttypes>    // PRId64 SCNd64
#include <numeric>      // accumulate, partial_sum, inner_product, iota, adjacent_difference
#include <vector>
#include <map>
#include <set>
#include <tuple>        // pair, tuple
#include <iostream>
#include <algorithm>
#include <utility>
#include <iterator>
template <typename It>
struct iter_range : std::pair<It, It> {
    typedef std::pair<It, It> base_t;
    using base_t::base_t;
    It begin() { return base_t::first; }
    It end() { return base_t::second; }
};
template <typename It>
iter_range<std::reverse_iterator<It>> rev(const iter_range<It> &origin) {
    using rev_t = std::reverse_iterator<It>;
    return {rev_t(origin.second), rev_t(origin.first)};
}
template <typename Int = int>
struct int_iter {
    Int i;
    explicit int_iter(Int i = 0) : i(i) { }
    Int operator*() const { return i; }
    int_iter &operator++() { ++i; return *this; }
    int_iter &operator--() { --i; return *this; }
    int_iter operator+(Int step) const { return int_iter(i + step); }
    int_iter operator-(Int step) const { return int_iter(i - step); }
    Int operator-(const int_iter &that) const { return i - that.i; }
    int_iter &operator+=(Int step) { i += step; return *this; }
    int_iter &operator-=(Int step) { i -= step; return *this; }
    bool operator==(const int_iter &that) const { return  i == that.i; }
    bool operator!=(const int_iter &that) const { return !(*this == that); }
    Int operator[](Int n) { return i + n; }
    typedef Int difference_type;
    typedef Int value_type;
    typedef Int *pointer;
    typedef Int reference; // not a int container, never reference to int
    typedef std::random_access_iterator_tag iterator_category;
};
typedef iter_range<int_iter<>> range_t;
range_t range(int b, int e) { return {int_iter<>(b), int_iter<>(e > b ? e : b)}; }
range_t range(int n) { return range(0, n); }
range_t nrange(int n) { return range(1, n+1); }
range_t inrange(int b, int e) { return range(b, e + 1); }
using namespace std;    // use as solution header. name polution is fine.
#ifdef LOCAL_JUDGE
#  define pr_debug(...) fprintf(stderr, __VA_ARGS__)
#else
#  define pr_debug(...)
#endif
template <typename T>
bool chmax(T &m, const T &v) { if (v > m) return m = v, true; return false; }
template <typename T>
bool chmin(T &m, const T &v) { if (v < m) return m = v, true; return false; }
void fio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}
/* =====  SOLUTION START  ===== */
// Greedy is Good!
int n;
int arr[100005];
int a, b;
int main() {
    fio();
    cin >> n;
    for (int i : range(n))
        cin >> arr[i];
    sort(begin(arr), end(arr), std::greater<int>());
    cin >> a >> b;
    int ans = 0;
    while (a != b) {
        int drop = 1;
        for (int i : range(n)) {
            if (arr[i] <= drop) break; // small optimize
            int new_drop = a % arr[i];
            if (new_drop <= a - b) chmax(drop, new_drop);
        }
        ++ans;
        a -= drop;
    }
    cout << ans << endl;
    return 0;
}


/*
 * if you are interested in the reference code here,
 * see https://github.com/georeth/OJLIBS for more information
 *
 * Solution Author : Georeth Chow <georeth2010@gmail.com>
 */
#include <cstdio>
#include <cmath>
#include <cstring>      // memset
#include <cstdlib>      // malloc
#include <cstdint>      // int64_t
#include <cinttypes>    // PRId64 SCNd64
#include <numeric>      // accumulate, partial_sum, inner_product, iota, adjacent_difference
#include <vector>
#include <map>
#include <set>
#include <tuple>        // pair, tuple
#include <iostream>
#include <algorithm>
#include <utility>
#include <iterator>
template <typename It>
struct iter_range : std::pair<It, It> {
    typedef std::pair<It, It> base_t;
    using base_t::base_t;
    It begin() { return base_t::first; }
    It end() { return base_t::second; }
};
template <typename It>
iter_range<std::reverse_iterator<It>> rev(const iter_range<It> &origin) {
    using rev_t = std::reverse_iterator<It>;
    return {rev_t(origin.second), rev_t(origin.first)};
}
template <typename Int = int>
struct int_iter {
    Int i;
    explicit int_iter(Int i = 0) : i(i) { }
    Int operator*() const { return i; }
    int_iter &operator++() { ++i; return *this; }
    int_iter &operator--() { --i; return *this; }
    int_iter operator+(Int step) const { return int_iter(i + step); }
    int_iter operator-(Int step) const { return int_iter(i - step); }
    Int operator-(const int_iter &that) const { return i - that.i; }
    int_iter &operator+=(Int step) { i += step; return *this; }
    int_iter &operator-=(Int step) { i -= step; return *this; }
    bool operator==(const int_iter &that) const { return  i == that.i; }
    bool operator!=(const int_iter &that) const { return !(*this == that); }
    Int operator[](Int n) { return i + n; }
    typedef Int difference_type;
    typedef Int value_type;
    typedef Int *pointer;
    typedef Int reference; // not a int container, never reference to int
    typedef std::random_access_iterator_tag iterator_category;
};
typedef iter_range<int_iter<>> range_t;
range_t range(int b, int e) { return {int_iter<>(b), int_iter<>(e > b ? e : b)}; }
range_t range(int n) { return range(0, n); }
range_t nrange(int n) { return range(1, n+1); }
range_t inrange(int b, int e) { return range(b, e + 1); }
using namespace std;    // use as solution header. name polution is fine.
#ifdef LOCAL_JUDGE
#  define pr_debug(...) fprintf(stderr, __VA_ARGS__)
#else
#  define pr_debug(...)
#endif
template <typename T>
bool chmax(T &m, const T &v) { if (v > m) return m = v, true; return false; }
template <typename T>
bool chmin(T &m, const T &v) { if (v < m) return m = v, true; return false; }
void fio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}
#include <list>
/* =====  SOLUTION START  ===== */
// Greedy is Good!
int n;
int arr[100005];
int a, b;
int main() {
    fio();
    cin >> n;
    for (int i : range(n))
        cin >> arr[i];
    sort(arr, arr + n, std::greater<int>());
    list<int> lst(arr, arr + n);
    cin >> a >> b;
    int ans = 0;
    while (a != b) {
        int drop = 1;
        auto it = lst.begin();
        while (it != lst.end()) {
            if (*it <= drop) break; // small optimize
            int new_drop = a % *it;
            if (new_drop <= a - b) chmax(drop, new_drop), ++it;
            else it = lst.erase(it); // another optimize
        }
        ++ans;
        a -= drop;
    }
    cout << ans << endl;
    return 0;
}


/*
 * if you are interested in the reference code here,
 * see https://github.com/georeth/OJLIBS for more information
 *
 * Solution Author : Georeth Chow <georeth2010@gmail.com>
 */
#include <cstdio>
#include <cmath>
#include <cstring>      // memset
#include <cstdlib>      // malloc
#include <cstdint>      // int64_t
#include <cinttypes>    // PRId64 SCNd64
#include <numeric>      // accumulate, partial_sum, inner_product, iota, adjacent_difference
#include <vector>
#include <map>
#include <set>
#include <tuple>        // pair, tuple
#include <iostream>
#include <algorithm>
#include <utility>
#include <iterator>
template <typename It>
struct iter_range : std::pair<It, It> {
    typedef std::pair<It, It> base_t;
    using base_t::base_t;
    It begin() { return base_t::first; }
    It end() { return base_t::second; }
};
template <typename It>
iter_range<std::reverse_iterator<It>> rev(const iter_range<It> &origin) {
    using rev_t = std::reverse_iterator<It>;
    return {rev_t(origin.second), rev_t(origin.first)};
}
template <typename Int = int>
struct int_iter {
    Int i;
    explicit int_iter(Int i = 0) : i(i) { }
    Int operator*() const { return i; }
    int_iter &operator++() { ++i; return *this; }
    int_iter &operator--() { --i; return *this; }
    int_iter operator+(Int step) const { return int_iter(i + step); }
    int_iter operator-(Int step) const { return int_iter(i - step); }
    Int operator-(const int_iter &that) const { return i - that.i; }
    int_iter &operator+=(Int step) { i += step; return *this; }
    int_iter &operator-=(Int step) { i -= step; return *this; }
    bool operator==(const int_iter &that) const { return  i == that.i; }
    bool operator!=(const int_iter &that) const { return !(*this == that); }
    Int operator[](Int n) { return i + n; }
    typedef Int difference_type;
    typedef Int value_type;
    typedef Int *pointer;
    typedef Int reference; // not a int container, never reference to int
    typedef std::random_access_iterator_tag iterator_category;
};
typedef iter_range<int_iter<>> range_t;
range_t range(int b, int e) { return {int_iter<>(b), int_iter<>(e > b ? e : b)}; }
range_t range(int n) { return range(0, n); }
range_t nrange(int n) { return range(1, n+1); }
range_t inrange(int b, int e) { return range(b, e + 1); }
using namespace std;    // use as solution header. name polution is fine.
#ifdef LOCAL_JUDGE
#  define pr_debug(...) fprintf(stderr, __VA_ARGS__)
#else
#  define pr_debug(...)
#endif
template <typename T>
bool chmax(T &m, const T &v) { if (v > m) return m = v, true; return false; }
template <typename T>
bool chmin(T &m, const T &v) { if (v < m) return m = v, true; return false; }
void fio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}
#include <list>
/* =====  SOLUTION START  ===== */
// Greedy is Good!
int n;
int arr[100005];
int a, b;
int main() {
    fio();
    cin >> n;
    for (int i : range(n))
        cin >> arr[i];
    sort(arr, arr + n, std::greater<int>());
    n = unique(arr, arr + n) - arr; // optimize 3
    list<int> lst(arr, arr + n);
    cin >> a >> b;
    int ans = 0;
    while (a != b) {
        int drop = 1;
        auto it = lst.begin();
        while (it != lst.end()) {
            if (*it <= drop) break; // small optimize 1 (TLE on 15 ...)
            int new_drop = a % *it;
            if (new_drop <= a - b) chmax(drop, new_drop), ++it;
            else it = lst.erase(it); // another optimize 2 (TLE on 28 ...)
        }
        ++ans;
        a -= drop;
    }
    // new idea : maintain all remainders
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cstdlib>
#include <string>
#include <complex>
#include <bitset>
#include <cmath>
#include <stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<pii, int> piii;
typedef pair<pll, ll> plll;
typedef pair<pdd, double> pddd;
typedef complex<double> cpx;
#define mst(x,v) memset(x,v,sizeof(x))
#define rgs register
#define rp(k,x,v) for(rgs int k = x;k<v;++k)
#define rps(s) for(rgs int i = 0;s[i];++i)
#define RP(k,x,v) for(rgs int k = x;k<=v;++k)
#define lp(k,x,v) for(rgs int k = x;k>v;--k)
#define LP(k,x,v) for(rgs int k = x;k>=v;--k)
#define lowbit(x) (x&-x)
#define adde(u,v) edg[++ecnt]=Edge(u,v,g[u]),g[u]=ecnt
#define addew(u,v,w) edg[++ecnt]=Edge(u,v,g[u],w),g[u]=ecnt
#define addedg(u,v,w,cap) edg[++ecnt]=Edge(u,v,g[u],w,cap),g[u]=ecnt,edg[++ecnt]=Edge(v,u,g[v],-w,0),g[v]=ecnt
#define fson(x) for(rgs int i = g[x];~i;i=edg[i].next)
#define LB lower_bound
#define UB upper_bound
#define inp(n,a) RP(i,1,n) ru(a[i]);
#define mpt int mid = l+r>>1;
#define all(a) a.begin(),a.end()
#define inr (ql<=l && r<=qr)
#define upmax(a,b) a=max(a,b)
#define upmin(a,b) a=min(a,b)
const int INF = 1 << 29;
const ll LINF = 1LL << 60;
const double inf = 1e15;
ll mod = 1e9 + 7;
char READ_DATA;
int SIGNAL_INPUT;
template <typename Type>
inline Type ru(Type &v)
{
	SIGNAL_INPUT = 1;
	while ((READ_DATA = getchar()) < '0' || READ_DATA > '9')
		if (READ_DATA == '-')
			SIGNAL_INPUT = -1;
		else if (READ_DATA == EOF)
			return EOF;
	v = READ_DATA - '0';
	while ((READ_DATA = getchar()) >= '0' && READ_DATA <= '9')
		v = v * 10 + READ_DATA - '0';
	v *= SIGNAL_INPUT;
	return v;
}
inline ll modru(ll &v)
{
	ll p = 0;
	SIGNAL_INPUT = 1;
	while ((READ_DATA = getchar()) < '0' || READ_DATA > '9')
		if (READ_DATA == '-')
			SIGNAL_INPUT = -1;
		else if (READ_DATA == EOF)
			return EOF;
	p = v = READ_DATA - '0';
	while ((READ_DATA = getchar()) >= '0' && READ_DATA <= '9')
	{
		v = (v * 10 + READ_DATA - '0') % mod;
		p = (p * 10 + READ_DATA - '0') % (mod - 1);
	}
	v *= SIGNAL_INPUT;
	return p;
}
template<typename A, typename B > inline char ru(A&x, B&y) { if (ru(x) == EOF) return EOF; ru(y); return 2; }
template<typename A, typename B, typename C>inline char ru(A&x, B&y, C&z) { if (ru(x) == EOF) return EOF; ru(y); ru(z); return 3; }
template<typename A, typename B, typename C, typename D>inline char ru(A&x, B&y, C&z, D&w) { if (ru(x) == EOF) return EOF; ru(y); ru(z); ru(w); return 4; }

struct Edge
{
	int  u, v, next;
	ll w, cap, flow;
	Edge(int _u = 0, int _v = 0, int nxt = -1, ll _w = 1, ll _cap = 0)
	{
		u = _u;
		v = _v;
		w = _w;
		cap = _cap;
		flow = 0;
		next = nxt;
	}

	int operator<(const Edge &b) const
	{
		return w < b.w;
	}
};

const int maxn = 1e3 + 10, N = 2e6 + 1;
double eps = 1e-7, pi = acos(-1.0);
ull seed = 131, smod = (1LL << 32) - 267;

int a, b, n, y, minv, ans;
vector<int> x, tmp;

int main()
{
	ru(n);
	while (n--)
	{
		ru(y);
		x.push_back(y);
	}
	sort(all(x));
	unique(all(x));
	ru(a, b);
	while (a != b)
	{
		minv = a - 1;
		rp(i, 0, x.size())
		{
			y = a - a%x[i];
			if (y >= b)
			{
				upmin(minv, y);
				tmp.push_back(x[i]);
			}
		}
		a = minv;
		x = tmp;
		tmp.clear();
		++ans;
	}
	cout << ans;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cstdlib>
#include <string>
#include <complex>
#include <bitset>
#include <cmath>
#include <stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<pii, int> piii;
typedef pair<pll, ll> plll;
typedef pair<pdd, double> pddd;
typedef complex<double> cpx;
#define mst(x,v) memset(x,v,sizeof(x))
#define rgs register
#define rp(k,x,v) for(rgs int k = x;k<v;++k)
#define rps(s) for(rgs int i = 0;s[i];++i)
#define RP(k,x,v) for(rgs int k = x;k<=v;++k)
#define lp(k,x,v) for(rgs int k = x;k>v;--k)
#define LP(k,x,v) for(rgs int k = x;k>=v;--k)
#define lowbit(x) (x&-x)
#define adde(u,v) edg[++ecnt]=Edge(u,v,g[u]),g[u]=ecnt
#define addew(u,v,w) edg[++ecnt]=Edge(u,v,g[u],w),g[u]=ecnt
#define addedg(u,v,w,cap) edg[++ecnt]=Edge(u,v,g[u],w,cap),g[u]=ecnt,edg[++ecnt]=Edge(v,u,g[v],-w,0),g[v]=ecnt
#define fson(x) for(rgs int i = g[x];~i;i=edg[i].next)
#define LB lower_bound
#define UB upper_bound
#define inp(n,a) RP(i,1,n) ru(a[i]);
#define mpt int mid = l+r>>1;
#define all(a) a.begin(),a.end()
#define inr (ql<=l && r<=qr)
#define upmax(a,b) a=max(a,b)
#define upmin(a,b) a=min(a,b)
const int INF = 1 << 29;
const ll LINF = 1LL << 60;
const double inf = 1e15;
ll mod = 1e9 + 7;
char READ_DATA;
int SIGNAL_INPUT;
template <typename Type>
inline Type ru(Type &v)
{
	SIGNAL_INPUT = 1;
	while ((READ_DATA = getchar()) < '0' || READ_DATA > '9')
		if (READ_DATA == '-')
			SIGNAL_INPUT = -1;
		else if (READ_DATA == EOF)
			return EOF;
	v = READ_DATA - '0';
	while ((READ_DATA = getchar()) >= '0' && READ_DATA <= '9')
		v = v * 10 + READ_DATA - '0';
	v *= SIGNAL_INPUT;
	return v;
}
inline ll modru(ll &v)
{
	ll p = 0;
	SIGNAL_INPUT = 1;
	while ((READ_DATA = getchar()) < '0' || READ_DATA > '9')
		if (READ_DATA == '-')
			SIGNAL_INPUT = -1;
		else if (READ_DATA == EOF)
			return EOF;
	p = v = READ_DATA - '0';
	while ((READ_DATA = getchar()) >= '0' && READ_DATA <= '9')
	{
		v = (v * 10 + READ_DATA - '0') % mod;
		p = (p * 10 + READ_DATA - '0') % (mod - 1);
	}
	v *= SIGNAL_INPUT;
	return p;
}
template<typename A, typename B > inline char ru(A&x, B&y) { if (ru(x) == EOF) return EOF; ru(y); return 2; }
template<typename A, typename B, typename C>inline char ru(A&x, B&y, C&z) { if (ru(x) == EOF) return EOF; ru(y); ru(z); return 3; }
template<typename A, typename B, typename C, typename D>inline char ru(A&x, B&y, C&z, D&w) { if (ru(x) == EOF) return EOF; ru(y); ru(z); ru(w); return 4; }

struct Edge
{
	int  u, v, next;
	ll w, cap, flow;
	Edge(int _u = 0, int _v = 0, int nxt = -1, ll _w = 1, ll _cap = 0)
	{
		u = _u;
		v = _v;
		w = _w;
		cap = _cap;
		flow = 0;
		next = nxt;
	}

	int operator<(const Edge &b) const
	{
		return w < b.w;
	}
};

const int maxn = 1e3 + 10, N = 2e6 + 1;
double eps = 1e-7, pi = acos(-1.0);
ull seed = 131, smod = (1LL << 32) - 267;

int a, b, n, y, minv, ans;
vector<int> x, tmp;

int main()
{
	ru(n);
	while (n--)
	{
		ru(y);
		x.push_back(y);
	}
	sort(all(x));
	unique(all(x));
	ru(a, b);
	while (a != b)
	{
		minv = a - 1;
		rp(i, 0, x.size())
		{
			y = a - a%x[i];
			if (y >= b)
			{
				upmin(minv, y);
				tmp.push_back(x[i]);
			}
		}
		a = minv;
		x.clear();
		rp(i, 0, tmp.size())
			x.push_back(tmp[i]);
		tmp.clear();
		++ans;
	}
	cout << ans;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cstdlib>
#include <string>
#include <complex>
#include <bitset>
#include <cmath>
#include <stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<pii, int> piii;
typedef pair<pll, ll> plll;
typedef pair<pdd, double> pddd;
typedef complex<double> cpx;
#define mst(x,v) memset(x,v,sizeof(x))
#define rgs register
#define rp(k,x,v) for(rgs int k = x;k<v;++k)
#define rps(s) for(rgs int i = 0;s[i];++i)
#define RP(k,x,v) for(rgs int k = x;k<=v;++k)
#define lp(k,x,v) for(rgs int k = x;k>v;--k)
#define LP(k,x,v) for(rgs int k = x;k>=v;--k)
#define lowbit(x) (x&-x)
#define adde(u,v) edg[++ecnt]=Edge(u,v,g[u]),g[u]=ecnt
#define addew(u,v,w) edg[++ecnt]=Edge(u,v,g[u],w),g[u]=ecnt
#define addedg(u,v,w,cap) edg[++ecnt]=Edge(u,v,g[u],w,cap),g[u]=ecnt,edg[++ecnt]=Edge(v,u,g[v],-w,0),g[v]=ecnt
#define fson(x) for(rgs int i = g[x];~i;i=edg[i].next)
#define LB lower_bound
#define UB upper_bound
#define inp(n,a) RP(i,1,n) ru(a[i]);
#define mpt int mid = l+r>>1;
#define all(a) a.begin(),a.end()
#define inr (ql<=l && r<=qr)
#define upmax(a,b) a=max(a,b)
#define upmin(a,b) a=min(a,b)
const int INF = 1 << 29;
const ll LINF = 1LL << 60;
const double inf = 1e15;
ll mod = 1e9 + 7;
char READ_DATA;
int SIGNAL_INPUT;
template <typename Type>
inline Type ru(Type &v)
{
	SIGNAL_INPUT = 1;
	while ((READ_DATA = getchar()) < '0' || READ_DATA > '9')
		if (READ_DATA == '-')
			SIGNAL_INPUT = -1;
		else if (READ_DATA == EOF)
			return EOF;
	v = READ_DATA - '0';
	while ((READ_DATA = getchar()) >= '0' && READ_DATA <= '9')
		v = v * 10 + READ_DATA - '0';
	v *= SIGNAL_INPUT;
	return v;
}
inline ll modru(ll &v)
{
	ll p = 0;
	SIGNAL_INPUT = 1;
	while ((READ_DATA = getchar()) < '0' || READ_DATA > '9')
		if (READ_DATA == '-')
			SIGNAL_INPUT = -1;
		else if (READ_DATA == EOF)
			return EOF;
	p = v = READ_DATA - '0';
	while ((READ_DATA = getchar()) >= '0' && READ_DATA <= '9')
	{
		v = (v * 10 + READ_DATA - '0') % mod;
		p = (p * 10 + READ_DATA - '0') % (mod - 1);
	}
	v *= SIGNAL_INPUT;
	return p;
}
template<typename A, typename B > inline char ru(A&x, B&y) { if (ru(x) == EOF) return EOF; ru(y); return 2; }
template<typename A, typename B, typename C>inline char ru(A&x, B&y, C&z) { if (ru(x) == EOF) return EOF; ru(y); ru(z); return 3; }
template<typename A, typename B, typename C, typename D>inline char ru(A&x, B&y, C&z, D&w) { if (ru(x) == EOF) return EOF; ru(y); ru(z); ru(w); return 4; }

struct Edge
{
	int  u, v, next;
	ll w, cap, flow;
	Edge(int _u = 0, int _v = 0, int nxt = -1, ll _w = 1, ll _cap = 0)
	{
		u = _u;
		v = _v;
		w = _w;
		cap = _cap;
		flow = 0;
		next = nxt;
	}

	int operator<(const Edge &b) const
	{
		return w < b.w;
	}
};

const int maxn = 1e5 + 10, N = 2e6 + 1;
double eps = 1e-7, pi = acos(-1.0);
ull seed = 131, smod = (1LL << 32) - 267;

int a, b, n, y, minv, ans;
vector<int> x, tmp;
int p[maxn];

int main()
{
	ru(n);
	rp(i, 0, n) ru(p[i]);
	sort(p, p + n);
	n = unique(p, p + n) - p;
	rp(i, 0, n) x.push_back(p[i]);
	ru(a, b);
	while (a != b)
	{
		minv = a - 1;
		rp(i, 0, x.size())
		{
			y = a - a%x[i];
			if (y >= b)
			{
				upmin(minv, y);
				tmp.push_back(x[i]);
			}
		}
		a = minv;
		x.clear();
		rp(i, 0, tmp.size()) if(a-a%tmp[i]>=b)
			x.push_back(tmp[i]);
		tmp.clear();
		++ans;
	}
	cout << ans;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cstdlib>
#include <string>
#include <complex>
#include <bitset>
#include <cmath>
#include <stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<pii, int> piii;
typedef pair<pll, ll> plll;
typedef pair<pdd, double> pddd;
typedef complex<double> cpx;
#define mst(x,v) memset(x,v,sizeof(x))
#define rgs register
#define rp(k,x,v) for(rgs int k = x;k<v;++k)
#define rps(s) for(rgs int i = 0;s[i];++i)
#define RP(k,x,v) for(rgs int k = x;k<=v;++k)
#define lp(k,x,v) for(rgs int k = x;k>v;--k)
#define LP(k,x,v) for(rgs int k = x;k>=v;--k)
#define lowbit(x) (x&-x)
#define adde(u,v) edg[++ecnt]=Edge(u,v,g[u]),g[u]=ecnt
#define addew(u,v,w) edg[++ecnt]=Edge(u,v,g[u],w),g[u]=ecnt
#define addedg(u,v,w,cap) edg[++ecnt]=Edge(u,v,g[u],w,cap),g[u]=ecnt,edg[++ecnt]=Edge(v,u,g[v],-w,0),g[v]=ecnt
#define fson(x) for(rgs int i = g[x];~i;i=edg[i].next)
#define LB lower_bound
#define UB upper_bound
#define inp(n,a) RP(i,1,n) ru(a[i]);
#define mpt int mid = l+r>>1;
#define all(a) a.begin(),a.end()
#define inr (ql<=l && r<=qr)
#define upmax(a,b) a=max(a,b)
#define upmin(a,b) a=min(a,b)
const int INF = 1 << 29;
const ll LINF = 1LL << 60;
const double inf = 1e15;
ll mod = 1e9 + 7;
char READ_DATA;
int SIGNAL_INPUT;
template <typename Type>
inline Type ru(Type &v)
{
	SIGNAL_INPUT = 1;
	while ((READ_DATA = getchar()) < '0' || READ_DATA > '9')
		if (READ_DATA == '-')
			SIGNAL_INPUT = -1;
		else if (READ_DATA == EOF)
			return EOF;
	v = READ_DATA - '0';
	while ((READ_DATA = getchar()) >= '0' && READ_DATA <= '9')
		v = v * 10 + READ_DATA - '0';
	v *= SIGNAL_INPUT;
	return v;
}
inline ll modru(ll &v)
{
	ll p = 0;
	SIGNAL_INPUT = 1;
	while ((READ_DATA = getchar()) < '0' || READ_DATA > '9')
		if (READ_DATA == '-')
			SIGNAL_INPUT = -1;
		else if (READ_DATA == EOF)
			return EOF;
	p = v = READ_DATA - '0';
	while ((READ_DATA = getchar()) >= '0' && READ_DATA <= '9')
	{
		v = (v * 10 + READ_DATA - '0') % mod;
		p = (p * 10 + READ_DATA - '0') % (mod - 1);
	}
	v *= SIGNAL_INPUT;
	return p;
}
template<typename A, typename B > inline char ru(A&x, B&y) { if (ru(x) == EOF) return EOF; ru(y); return 2; }
template<typename A, typename B, typename C>inline char ru(A&x, B&y, C&z) { if (ru(x) == EOF) return EOF; ru(y); ru(z); return 3; }
template<typename A, typename B, typename C, typename D>inline char ru(A&x, B&y, C&z, D&w) { if (ru(x) == EOF) return EOF; ru(y); ru(z); ru(w); return 4; }

struct Edge
{
	int  u, v, next;
	ll w, cap, flow;
	Edge(int _u = 0, int _v = 0, int nxt = -1, ll _w = 1, ll _cap = 0)
	{
		u = _u;
		v = _v;
		w = _w;
		cap = _cap;
		flow = 0;
		next = nxt;
	}

	int operator<(const Edge &b) const
	{
		return w < b.w;
	}
};

const int maxn = 1e3 + 10, N = 2e6 + 1;
double eps = 1e-7, pi = acos(-1.0);
ull seed = 131, smod = (1LL << 32) - 267;

int a, b, n, y, minv;
vector<int> x, tmp;

int main()
{
	ru(n);
	while (n--)
	{
		ru(y);
		x.push_back(y);
	}
	sort(all(x));
	unique(all(x));
	ru(a, b);
	while (a != b)
	{
		minv = a - 1;
		rp(i, 0, x.size())
		{
			y = a - a%x[i];
			if (y >= b)
			{
				upmin(minv, y);
				tmp.push_back(x[i]);
			}
		}
		a = minv;
		x = tmp;
	}
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cstdlib>
#include <string>
#include <complex>
#include <bitset>
#include <cmath>
#include <stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<pii, int> piii;
typedef pair<pll, ll> plll;
typedef pair<pdd, double> pddd;
typedef complex<double> cpx;
#define mst(x,v) memset(x,v,sizeof(x))
#define rgs register
#define rp(k,x,v) for(rgs int k = x;k<v;++k)
#define rps(s) for(rgs int i = 0;s[i];++i)
#define RP(k,x,v) for(rgs int k = x;k<=v;++k)
#define lp(k,x,v) for(rgs int k = x;k>v;--k)
#define LP(k,x,v) for(rgs int k = x;k>=v;--k)
#define lowbit(x) (x&-x)
#define adde(u,v) edg[++ecnt]=Edge(u,v,g[u]),g[u]=ecnt
#define addew(u,v,w) edg[++ecnt]=Edge(u,v,g[u],w),g[u]=ecnt
#define addedg(u,v,w,cap) edg[++ecnt]=Edge(u,v,g[u],w,cap),g[u]=ecnt,edg[++ecnt]=Edge(v,u,g[v],-w,0),g[v]=ecnt
#define fson(x) for(rgs int i = g[x];~i;i=edg[i].next)
#define LB lower_bound
#define UB upper_bound
#define inp(n,a) RP(i,1,n) ru(a[i]);
#define mpt int mid = l+r>>1;
#define all(a) a.begin(),a.end()
#define inr (ql<=l && r<=qr)
#define upmax(a,b) a=max(a,b)
#define upmin(a,b) a=min(a,b)
const int INF = 1 << 29;
const ll LINF = 1LL << 60;
const double inf = 1e15;
ll mod = 1e9 + 7;
char READ_DATA;
int SIGNAL_INPUT;
template <typename Type>
inline Type ru(Type &v)
{
	SIGNAL_INPUT = 1;
	while ((READ_DATA = getchar()) < '0' || READ_DATA > '9')
		if (READ_DATA == '-')
			SIGNAL_INPUT = -1;
		else if (READ_DATA == EOF)
			return EOF;
	v = READ_DATA - '0';
	while ((READ_DATA = getchar()) >= '0' && READ_DATA <= '9')
		v = v * 10 + READ_DATA - '0';
	v *= SIGNAL_INPUT;
	return v;
}
inline ll modru(ll &v)
{
	ll p = 0;
	SIGNAL_INPUT = 1;
	while ((READ_DATA = getchar()) < '0' || READ_DATA > '9')
		if (READ_DATA == '-')
			SIGNAL_INPUT = -1;
		else if (READ_DATA == EOF)
			return EOF;
	p = v = READ_DATA - '0';
	while ((READ_DATA = getchar()) >= '0' && READ_DATA <= '9')
	{
		v = (v * 10 + READ_DATA - '0') % mod;
		p = (p * 10 + READ_DATA - '0') % (mod - 1);
	}
	v *= SIGNAL_INPUT;
	return p;
}
template<typename A, typename B > inline char ru(A&x, B&y) { if (ru(x) == EOF) return EOF; ru(y); return 2; }
template<typename A, typename B, typename C>inline char ru(A&x, B&y, C&z) { if (ru(x) == EOF) return EOF; ru(y); ru(z); return 3; }
template<typename A, typename B, typename C, typename D>inline char ru(A&x, B&y, C&z, D&w) { if (ru(x) == EOF) return EOF; ru(y); ru(z); ru(w); return 4; }

struct Edge
{
	int  u, v, next;
	ll w, cap, flow;
	Edge(int _u = 0, int _v = 0, int nxt = -1, ll _w = 1, ll _cap = 0)
	{
		u = _u;
		v = _v;
		w = _w;
		cap = _cap;
		flow = 0;
		next = nxt;
	}

	int operator<(const Edge &b) const
	{
		return w < b.w;
	}
};

const int maxn = 1e3 + 10, N = 2e6 + 1;
double eps = 1e-7, pi = acos(-1.0);
ull seed = 131, smod = (1LL << 32) - 267;

int a, b, n, y, minv, ans;
vector<int> x, tmp;
int p[maxn];

int main()
{
	ru(n);
	rp(i, 0, n) ru(p[i]);
	sort(p, p + n);
	n = unique(p, p + n) - p;
	rp(i, 0, n) x.push_back(p[i]);
	ru(a, b);
	while (a != b)
	{
		minv = a - 1;
		rp(i, 0, x.size())
		{
			y = a - a%x[i];
			if (y >= b)
			{
				upmin(minv, y);
				tmp.push_back(x[i]);
			}
		}
		a = minv;
		x.clear();
		rp(i, 0, tmp.size()) if(a-a%tmp[i]>=b)
			x.push_back(tmp[i]);
		tmp.clear();
		++ans;
	}
	cout << ans;
}