/* *********************************************************************
   *                       Problem: --------------                     *
   *                   Runtime: 0.000 sec; Rank: 0000                  *
   *                     Algo Used: ----------------                   *
   *                    Solved By : Niloy - JU-CSE-21                  *
   ********************************************************************* */
#include <bits/stdc++.h>                            //all pre-compiled header files
/* ********************
   *     Defines      *
   ******************** */
#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define FOR(i,s,e) for(i=s;i<=e;i++)                //for loop with 1 increment
#define FORR(i,s,e) for(i=s;i>=e;i--)                //for loop with 1 increment
#define For(i,s,e,d) for(i=s;i<=e;i+=d)             //for loop with manual increment
#define _For(i,s,e,d) for(i=s;i>=e;i-=d)             //for loop with manual increment
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define SET(a,i) memset(a,i,sizeof a)               //setting array to specefic value
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define S1(a) scanf("%d",&a)                        //scan one int
#define S2(a,b) scanf("%d%d",&a,&b)                 //scan two int
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)          //scan three int
#define SL1(a) scanf("%lld",&a)                     //scanf one long long
#define SL2(a,b) scanf("%lld%lld",&a,&b)            //scanf two long long
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)   //scanf two long long
#define CHR getchar()                               //avoid the newline character problem
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define ULL unsigned long long                      //unsigned long long sort form
#define MX 10500                                    //MAX size/value
#define PB(x) push_back(x)                          //push in vector/string
#define PP pop_back()                               //pop from vector
#define PF(x) push_front(x)                         //push in vector/string/deque from front
#define PPF(x) pop_front()                          //pop from vector/deque from front
#define IN(x) insert(x)                             //insert element in set
#define PS(x) push(x)                               //push element in stack/queue
#define P() pop()                                   //pop element from stack/queue
#define SZ() size()                                 //return size
#define MOD 1000000007                              //mod value
#define INF (1<<28)                                 //infinity value
#define Y 1                                         //true value
#define N 0                                         //false value

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> T gcd(T a,T b){if (!b) return a;return gcd(b,a%b);}
template <typename T> T POW(T b,T p){if (p == 0) return 1;if (p%2 == 0){T s = POW(b,p/2);return s*s;}return b*POW(b,p-1);}

int tree[4*1000050];
bool vis[1000050];

void Insert(int idx,int l,int r,int val)
{
    if (l == r)
    {
        tree[idx] = val;
        return ;
    }

    int mid = (l+r)>>1, lft = idx<<1, rgt = lft|1;

    if (val<=mid)       Insert(lft,l,mid,val);
    else                Insert(rgt,mid+1,r,val);

    tree[idx] = max(tree[lft],tree[rgt]);
}

int Query(int idx,int l,int r,int st,int ed)
{
    //cout << l << "," << r << endl;
    if (st<=l && r<=ed)         return tree[idx];

    int mid = (l+r)>>1, lft = idx<<1, rgt = lft|1;

    if (ed<=mid)                return Query(lft,l,mid,st,ed);
    else if (st>mid)            return Query(rgt,mid+1,r,st,ed);
    else                        return max(Query(lft,l,mid,st,ed),Query(rgt,mid+1,r,st,ed));
}

int main()
{
    int a[100005];

    int n,k;

    int mx = -INF,mn = INF;

    int i;

    cin >> n >> k;

    FOR(i,0,n-1)
    {
        cin >> a[i];
        mn = min(mn,a[i]);
        mx = max(mx,a[i]);
    }

    FOR(i,0,n-1)
    {
        if (!vis[a[i]])
        {
            Insert(1,1,mx,a[i]);

            vis[a[i]] = 1;
        }
    }

    a[n] = INF;

    FORR(i,mn,1)
    {
        int tmp = i;
        int dif = -INF;

        //cout << i << endl;

        int prev = -1;

        while (tmp <= mx)
        {
            int Mx = Query(1,1,mx,tmp,min(tmp+i-1,mx));

            //cout << tmp << "->" << Mx << " & " << tmp << "->" << tmp+i-1 << endl;

            if (Mx)
            {
                dif = max(dif,Mx-tmp);
            }

            tmp += i;
        }

        //cout << endl;

        if (dif <= k)
        {
            break;
        }
    }
    cout << i << endl;

}


/* *********************************************************************
   *                       Problem: --------------                     *
   *                   Runtime: 0.000 sec; Rank: 0000                  *
   *                     Algo Used: ----------------                   *
   *                    Solved By : Niloy - JU-CSE-21                  *
   ********************************************************************* */
#include <bits/stdc++.h>                            //all pre-compiled header files
/* ********************
   *     Defines      *
   ******************** */
#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define FOR(i,s,e) for(i=s;i<=e;i++)                //for loop with 1 increment
#define FORR(i,s,e) for(i=s;i>=e;i--)                //for loop with 1 increment
#define For(i,s,e,d) for(i=s;i<=e;i+=d)             //for loop with manual increment
#define _For(i,s,e,d) for(i=s;i>=e;i-=d)             //for loop with manual increment
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define SET(a,i) memset(a,i,sizeof a)               //setting array to specefic value
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define S1(a) scanf("%d",&a)                        //scan one int
#define S2(a,b) scanf("%d%d",&a,&b)                 //scan two int
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)          //scan three int
#define SL1(a) scanf("%lld",&a)                     //scanf one long long
#define SL2(a,b) scanf("%lld%lld",&a,&b)            //scanf two long long
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)   //scanf two long long
#define CHR getchar()                               //avoid the newline character problem
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define ULL unsigned long long                      //unsigned long long sort form
#define MX 10500                                    //MAX size/value
#define PB(x) push_back(x)                          //push in vector/string
#define PP pop_back()                               //pop from vector
#define PF(x) push_front(x)                         //push in vector/string/deque from front
#define PPF(x) pop_front()                          //pop from vector/deque from front
#define IN(x) insert(x)                             //insert element in set
#define PS(x) push(x)                               //push element in stack/queue
#define P() pop()                                   //pop element from stack/queue
#define SZ() size()                                 //return size
#define MOD 1000000007                              //mod value
#define INF (1<<28)                                 //infinity value
#define Y 1                                         //true value
#define N 0                                         //false value

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> T gcd(T a,T b){if (!b) return a;return gcd(b,a%b);}
template <typename T> T POW(T b,T p){if (p == 0) return 1;if (p%2 == 0){T s = POW(b,p/2);return s*s;}return b*POW(b,p-1);}

int tree[4*1000050];
bool vis[1000050];

void Insert(int idx,int l,int r,int val)
{
    if (l == r)
    {
        tree[idx] = val;
        return ;
    }

    int mid = (l+r)>>1, lft = idx<<1, rgt = lft|1;

    if (val<=mid)       Insert(lft,l,mid,val);
    else                Insert(rgt,mid+1,r,val);

    tree[idx] = max(tree[lft],tree[rgt]);
}

int Query(int idx,int l,int r,int st,int ed)
{
    //cout << l << "," << r << endl;
    if (st<=l && r<=ed)         return tree[idx];

    int mid = (l+r)>>1, lft = idx<<1, rgt = lft|1;

    if (ed<=mid)                return Query(lft,l,mid,st,ed);
    else if (st>mid)            return Query(rgt,mid+1,r,st,ed);
    else                        return max(Query(lft,l,mid,st,ed),Query(rgt,mid+1,r,st,ed));
}

int main()
{
    int a[300005];

    int n,k;

    int mx = -INF,mn = INF;

    int i;

    cin >> n >> k;

    FOR(i,0,n-1)
    {
        S1(a[i]);
        mn = min(a[i],mn);
        mx = max(a[i],mx);
    }

    sort (a,a+n);
    a[n] = INF;

    FORR(i,mn,1)
    {
        int tmp = i;

        while (tmp <= mx)
        {
            int pos = upper_bound(a,a+n,tmp+k)-a;

            //cout << tmp << "->" << pos << "=" << a[pos] << endl;

            if (pos >= n)
            {
                cout << i << endl;
                return 0;
            }

            tmp = (a[pos]/i)*i;

            if (a[pos] - tmp > k)
                break;
        }
    }
    //cout << i << endl;

}


/* *********************************************************************
   *                       Problem: --------------                     *
   *                   Runtime: 0.000 sec; Rank: 0000                  *
   *                     Algo Used: ----------------                   *
   *                    Solved By : Niloy - JU-CSE-21                  *
   ********************************************************************* */
#include <bits/stdc++.h>                            //all pre-compiled header files
/* ********************
   *     Defines      *
   ******************** */
#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define FOR(i,s,e) for(i=s;i<=e;i++)                //for loop with 1 increment
#define FORR(i,s,e) for(i=s;i>=e;i--)                //for loop with 1 increment
#define For(i,s,e,d) for(i=s;i<=e;i+=d)             //for loop with manual increment
#define _For(i,s,e,d) for(i=s;i>=e;i-=d)             //for loop with manual increment
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define SET(a,i) memset(a,i,sizeof a)               //setting array to specefic value
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define S1(a) scanf("%d",&a)                        //scan one int
#define S2(a,b) scanf("%d%d",&a,&b)                 //scan two int
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)          //scan three int
#define SL1(a) scanf("%lld",&a)                     //scanf one long long
#define SL2(a,b) scanf("%lld%lld",&a,&b)            //scanf two long long
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)   //scanf two long long
#define CHR getchar()                               //avoid the newline character problem
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define ULL unsigned long long                      //unsigned long long sort form
#define MX 10500                                    //MAX size/value
#define PB(x) push_back(x)                          //push in vector/string
#define PP pop_back()                               //pop from vector
#define PF(x) push_front(x)                         //push in vector/string/deque from front
#define PPF(x) pop_front()                          //pop from vector/deque from front
#define IN(x) insert(x)                             //insert element in set
#define PS(x) push(x)                               //push element in stack/queue
#define P() pop()                                   //pop element from stack/queue
#define SZ() size()                                 //return size
#define MOD 1000000007                              //mod value
#define INF (1<<28)                                 //infinity value
#define Y 1                                         //true value
#define N 0                                         //false value

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> T gcd(T a,T b){if (!b) return a;return gcd(b,a%b);}
template <typename T> T POW(T b,T p){if (p == 0) return 1;if (p%2 == 0){T s = POW(b,p/2);return s*s;}return b*POW(b,p-1);}

bool vis[1000006];

int main()
{
    int a[100005];

    int n,k;

    int mx = -INF,mn = INF;

    int i;

    cin >> n >> k;

    FOR(i,0,n-1)        cin >> a[i],mn = min(mn,a[i]),mx = max(mx,a[i]),vis[a[i]] = 1;

    sort (a,a+n);

    a[n] = INF;

    FORR(i,mn,1)
    {
        int tmp = i;
        int dif = -INF;

        //cout << i << endl;

        int prev = -1;

        while (tmp <= mx)
        {
            int pos = lower_bound(a,a+n,tmp+i)-a-1;//-vis[tmp];

            //if (a[pos] < tmp)   pos++;
            //cout << tmp << ": " <<a[pos] << " ";

            if (a[pos] <=mx)
            {

                if (a[pos] == prev)
                {
                    dif = min(dif,a[pos]-tmp);
                    tmp += i;

                    //cout << dif << endl;
                    continue;
                }

                dif = max(dif,a[pos]-tmp);

                //cout << dif ;

                tmp += i;

                prev = a[pos];
            }

            tmp+= i;

            //cout << endl;
        }

        //cout << endl;

        if (dif <= k)
        {
            break;
        }
    }
    cout << i << endl;

}


/* *********************************************************************
   *                       Problem: --------------                     *
   *                   Runtime: 0.000 sec; Rank: 0000                  *
   *                     Algo Used: ----------------                   *
   *                    Solved By : Niloy - JU-CSE-21                  *
   ********************************************************************* */
#include <bits/stdc++.h>                            //all pre-compiled header files
/* ********************
   *     Defines      *
   ******************** */
#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define FOR(i,s,e) for(i=s;i<=e;i++)                //for loop with 1 increment
#define FORR(i,s,e) for(i=s;i>=e;i--)                //for loop with 1 increment
#define For(i,s,e,d) for(i=s;i<=e;i+=d)             //for loop with manual increment
#define _For(i,s,e,d) for(i=s;i>=e;i-=d)             //for loop with manual increment
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define SET(a,i) memset(a,i,sizeof a)               //setting array to specefic value
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define S1(a) scanf("%d",&a)                        //scan one int
#define S2(a,b) scanf("%d%d",&a,&b)                 //scan two int
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)          //scan three int
#define SL1(a) scanf("%lld",&a)                     //scanf one long long
#define SL2(a,b) scanf("%lld%lld",&a,&b)            //scanf two long long
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)   //scanf two long long
#define CHR getchar()                               //avoid the newline character problem
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define ULL unsigned long long                      //unsigned long long sort form
#define MX 10500                                    //MAX size/value
#define PB(x) push_back(x)                          //push in vector/string
#define PP pop_back()                               //pop from vector
#define PF(x) push_front(x)                         //push in vector/string/deque from front
#define PPF(x) pop_front()                          //pop from vector/deque from front
#define IN(x) insert(x)                             //insert element in set
#define PS(x) push(x)                               //push element in stack/queue
#define P() pop()                                   //pop element from stack/queue
#define SZ() size()                                 //return size
#define MOD 1000000007                              //mod value
#define INF (1<<28)                                 //infinity value
#define Y 1                                         //true value
#define N 0                                         //false value

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> T gcd(T a,T b){if (!b) return a;return gcd(b,a%b);}
template <typename T> T POW(T b,T p){if (p == 0) return 1;if (p%2 == 0){T s = POW(b,p/2);return s*s;}return b*POW(b,p-1);}

bool vis[1000006];

int main()
{
    int a[100005];

    int n,k;

    int mx = -INF,mn = INF;

    int i;

    cin >> n >> k;

    FOR(i,0,n-1)        cin >> a[i],mn = min(mn,a[i]),mx = max(mx,a[i]),vis[a[i]] = 1;

    sort (a,a+n);

    a[n] = INF;

    FORR(i,mn,1)
    {
        int tmp = i;
        int dif = -INF;

        cout << i << endl;

        int prev = -1;

        while (tmp <= mx)
        {
            int pos = lower_bound(a,a+n,tmp+i)-a-1;//-vis[tmp];

            //if (a[pos] < tmp)   pos++;
            //cout << tmp << ": " <<a[pos] << " ";

            if (a[pos] <=mx)
            {

                if (a[pos] == prev)
                {
                    dif = min(dif,a[pos]-tmp);
                    tmp += i;

                    //cout << dif << endl;
                    continue;
                }

                dif = max(dif,a[pos]-tmp);

                //cout << dif ;

                tmp += i;

                prev = a[pos];
            }

            tmp+= i;

            //cout << endl;
        }

        //cout << endl;

        if (dif <= k)
        {
            break;
        }
    }
    cout << i << endl;

}


/* *********************************************************************
   *                       Problem: --------------                     *
   *                   Runtime: 0.000 sec; Rank: 0000                  *
   *                     Algo Used: ----------------                   *
   *                    Solved By : Niloy - JU-CSE-21                  *
   ********************************************************************* */
#include <bits/stdc++.h>                            //all pre-compiled header files
/* ********************
   *     Defines      *
   ******************** */
#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define FOR(i,s,e) for(i=s;i<=e;i++)                //for loop with 1 increment
#define FORR(i,s,e) for(i=s;i>=e;i--)                //for loop with 1 increment
#define For(i,s,e,d) for(i=s;i<=e;i+=d)             //for loop with manual increment
#define _For(i,s,e,d) for(i=s;i>=e;i-=d)             //for loop with manual increment
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define SET(a,i) memset(a,i,sizeof a)               //setting array to specefic value
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define S1(a) scanf("%d",&a)                        //scan one int
#define S2(a,b) scanf("%d%d",&a,&b)                 //scan two int
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)          //scan three int
#define SL1(a) scanf("%lld",&a)                     //scanf one long long
#define SL2(a,b) scanf("%lld%lld",&a,&b)            //scanf two long long
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)   //scanf two long long
#define CHR getchar()                               //avoid the newline character problem
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define ULL unsigned long long                      //unsigned long long sort form
#define MX 10500                                    //MAX size/value
#define PB(x) push_back(x)                          //push in vector/string
#define PP pop_back()                               //pop from vector
#define PF(x) push_front(x)                         //push in vector/string/deque from front
#define PPF(x) pop_front()                          //pop from vector/deque from front
#define IN(x) insert(x)                             //insert element in set
#define PS(x) push(x)                               //push element in stack/queue
#define P() pop()                                   //pop element from stack/queue
#define SZ() size()                                 //return size
#define MOD 1000000007                              //mod value
#define INF (1<<28)                                 //infinity value
#define Y 1                                         //true value
#define N 0                                         //false value

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> T gcd(T a,T b){if (!b) return a;return gcd(b,a%b);}
template <typename T> T POW(T b,T p){if (p == 0) return 1;if (p%2 == 0){T s = POW(b,p/2);return s*s;}return b*POW(b,p-1);}

int tree[4*1000050];
bool vis[1000050];

void Insert(int idx,int l,int r,int val)
{
    if (l == r)
    {
        tree[idx] = val;
        return ;
    }

    int mid = (l+r)>>1, lft = idx<<1, rgt = lft|1;

    if (val<=mid)       Insert(lft,l,mid,val);
    else                Insert(rgt,mid+1,r,val);

    tree[idx] = max(tree[lft],tree[rgt]);
}

int Query(int idx,int l,int r,int st,int ed)
{
    //cout << l << "," << r << endl;
    if (st<=l && r<=ed)         return tree[idx];

    int mid = (l+r)>>1, lft = idx<<1, rgt = lft|1;

    if (ed<=mid)                return Query(lft,l,mid,st,ed);
    else if (st>mid)            return Query(rgt,mid+1,r,st,ed);
    else                        return max(Query(lft,l,mid,st,ed),Query(rgt,mid+1,r,st,ed));
}

int main()
{
    int a[100005];

    int n,k;

    int mx = -INF,mn = INF;

    int i;

    cin >> n >> k;

    FOR(i,0,n-1)
    {
        S1(a[i]);
        mn = min(a[i],mn);
        mx = max(a[i],mx);
    }

    sort (a,a+n);
    a[n] = INF;

    FORR(i,mn,1)
    {
        int tmp = i;

        while (tmp <= mx)
        {
            int pos = upper_bound(a,a+n,tmp+k)-a;

            cout << tmp << "->" << pos << "=" << a[pos] << endl;

            if (pos >= n)
            {
                cout << i << endl;
                return 0;
            }

            tmp = (a[pos]/i)*i;

            if (a[pos] - tmp > k)
                break;
        }
    }
    //cout << i << endl;

}


/* *********************************************************************
   *                       Problem: --------------                     *
   *                   Runtime: 0.000 sec; Rank: 0000                  *
   *                     Algo Used: ----------------                   *
   *                    Solved By : Niloy - JU-CSE-21                  *
   ********************************************************************* */
#include <bits/stdc++.h>                            //all pre-compiled header files
/* ********************
   *     Defines      *
   ******************** */
#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define FOR(i,s,e) for(i=s;i<=e;i++)                //for loop with 1 increment
#define FORR(i,s,e) for(i=s;i>=e;i--)                //for loop with 1 increment
#define For(i,s,e,d) for(i=s;i<=e;i+=d)             //for loop with manual increment
#define _For(i,s,e,d) for(i=s;i>=e;i-=d)             //for loop with manual increment
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define SET(a,i) memset(a,i,sizeof a)               //setting array to specefic value
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define S1(a) scanf("%d",&a)                        //scan one int
#define S2(a,b) scanf("%d%d",&a,&b)                 //scan two int
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)          //scan three int
#define SL1(a) scanf("%lld",&a)                     //scanf one long long
#define SL2(a,b) scanf("%lld%lld",&a,&b)            //scanf two long long
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)   //scanf two long long
#define CHR getchar()                               //avoid the newline character problem
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define ULL unsigned long long                      //unsigned long long sort form
#define MX 10500                                    //MAX size/value
#define PB(x) push_back(x)                          //push in vector/string
#define PP pop_back()                               //pop from vector
#define PF(x) push_front(x)                         //push in vector/string/deque from front
#define PPF(x) pop_front()                          //pop from vector/deque from front
#define IN(x) insert(x)                             //insert element in set
#define PS(x) push(x)                               //push element in stack/queue
#define P() pop()                                   //pop element from stack/queue
#define SZ() size()                                 //return size
#define MOD 1000000007                              //mod value
#define INF (1<<28)                                 //infinity value
#define Y 1                                         //true value
#define N 0                                         //false value

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> T gcd(T a,T b){if (!b) return a;return gcd(b,a%b);}
template <typename T> T POW(T b,T p){if (p == 0) return 1;if (p%2 == 0){T s = POW(b,p/2);return s*s;}return b*POW(b,p-1);}

int tree[4*1000050];
bool vis[1000050];

void Insert(int idx,int l,int r,int val)
{
    if (l == r)
    {
        tree[idx] = val;
        return ;
    }

    int mid = (l+r)>>1, lft = idx<<1, rgt = lft|1;

    if (val<=mid)       Insert(lft,l,mid,val);
    else                Insert(rgt,mid+1,r,val);

    tree[idx] = max(tree[lft],tree[rgt]);
}

int Query(int idx,int l,int r,int st,int ed)
{
    //cout << l << "," << r << endl;
    if (st<=l && r<=ed)         return tree[idx];

    int mid = (l+r)>>1, lft = idx<<1, rgt = lft|1;

    if (ed<=mid)                return Query(lft,l,mid,st,ed);
    else if (st>mid)            return Query(rgt,mid+1,r,st,ed);
    else                        return max(Query(lft,l,mid,st,ed),Query(rgt,mid+1,r,st,ed));
}

int main()
{
    int a[100005];

    int n,k;

    int mx = -INF,mn = INF;

    int i;

    cin >> n >> k;

    FOR(i,0,n-1)
    {
        cin >> a[i];
        mn = min(mn,a[i]);
        mx = max(mx,a[i]);
        vis[a[i]] = 1;
    }

    FOR(i,1,mx)         tree[i] = (vis[i]?i:tree[i-1]);

    FORR(i,mn,1)
    {
        int tmp = i;
        int dif = -INF;

        //cout << i << endl;

        int prev = -1;

        while (tmp <= mx)
        {
            int Mx = tree[min(tmp+i-1,mx)];

            //cout << tmp << "->" << Mx << " & " << tmp << "->" << tmp+i-1 << endl;

            if (Mx > tmp)
            {
                dif = max(dif,Mx-tmp);
            }

            tmp += i;
        }

        //cout << endl;

        if (dif <= k)
        {
            break;
        }
    }
    cout << i << endl;

}


/* *********************************************************************
   *                       Problem: --------------                     *
   *                   Runtime: 0.000 sec; Rank: 0000                  *
   *                     Algo Used: ----------------                   *
   *                    Solved By : Niloy - JU-CSE-21                  *
   ********************************************************************* */
#include <bits/stdc++.h>                            //all pre-compiled header files
/* ********************
   *     Defines      *
   ******************** */
#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define FOR(i,s,e) for(i=s;i<=e;i++)                //for loop with 1 increment
#define FORR(i,s,e) for(i=s;i>=e;i--)                //for loop with 1 increment
#define For(i,s,e,d) for(i=s;i<=e;i+=d)             //for loop with manual increment
#define _For(i,s,e,d) for(i=s;i>=e;i-=d)             //for loop with manual increment
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define SET(a,i) memset(a,i,sizeof a)               //setting array to specefic value
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define S1(a) scanf("%d",&a)                        //scan one int
#define S2(a,b) scanf("%d%d",&a,&b)                 //scan two int
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)          //scan three int
#define SL1(a) scanf("%lld",&a)                     //scanf one long long
#define SL2(a,b) scanf("%lld%lld",&a,&b)            //scanf two long long
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)   //scanf two long long
#define CHR getchar()                               //avoid the newline character problem
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define ULL unsigned long long                      //unsigned long long sort form
#define MX 10500                                    //MAX size/value
#define PB(x) push_back(x)                          //push in vector/string
#define PP pop_back()                               //pop from vector
#define PF(x) push_front(x)                         //push in vector/string/deque from front
#define PPF(x) pop_front()                          //pop from vector/deque from front
#define IN(x) insert(x)                             //insert element in set
#define PS(x) push(x)                               //push element in stack/queue
#define P() pop()                                   //pop element from stack/queue
#define SZ() size()                                 //return size
#define MOD 1000000007                              //mod value
#define INF (1<<28)                                 //infinity value
#define Y 1                                         //true value
#define N 0                                         //false value

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> T gcd(T a,T b){if (!b) return a;return gcd(b,a%b);}
template <typename T> T POW(T b,T p){if (p == 0) return 1;if (p%2 == 0){T s = POW(b,p/2);return s*s;}return b*POW(b,p-1);}

bool vis[1000006];

int main()
{
    int a[100005];

    int n,k;

    int mx = -INF,mn = INF;

    int i;

    cin >> n >> k;

    FOR(i,0,n-1)        cin >> a[i],mn = min(mn,a[i]),mx = max(mx,a[i]),vis[a[i]] = 1;

    sort (a,a+n);

    a[n] = INF;

    FORR(i,mn,1)
    {
        int tmp = i;
        int dif = -INF;

        //cout << i << endl;

        int prev = -1;

        while (tmp <= mx)
        {
            int pos = upper_bound(a,a+n,tmp)-a-vis[tmp];

            //if (a[pos] < tmp)   pos++;
            //cout << tmp << ": " <<a[pos] << " ";

            if (a[pos] <=mx)
            {

                if (a[pos] == prev)
                {
                    dif = min(dif,a[pos]-tmp);
                    tmp += i;

                    //cout << dif << endl;
                    continue;
                }

                dif = max(dif,a[pos]-tmp);

                //cout << dif ;

                //tmp += i;

                prev = a[pos];
            }

            tmp+= i;

            //cout << endl;
        }

        //cout << endl;

        if (dif <= k)
        {
            break;
        }
    }
    cout << i << endl;

}


/* *********************************************************************
   *                       Problem: --------------                     *
   *                   Runtime: 0.000 sec; Rank: 0000                  *
   *                     Algo Used: ----------------                   *
   *                    Solved By : Niloy - JU-CSE-21                  *
   ********************************************************************* */
#include <bits/stdc++.h>                            //all pre-compiled header files
/* ********************
   *     Defines      *
   ******************** */
#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define FOR(i,s,e) for(i=s;i<=e;i++)                //for loop with 1 increment
#define FORR(i,s,e) for(i=s;i>=e;i--)                //for loop with 1 increment
#define For(i,s,e,d) for(i=s;i<=e;i+=d)             //for loop with manual increment
#define _For(i,s,e,d) for(i=s;i>=e;i-=d)             //for loop with manual increment
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define SET(a,i) memset(a,i,sizeof a)               //setting array to specefic value
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define S1(a) scanf("%d",&a)                        //scan one int
#define S2(a,b) scanf("%d%d",&a,&b)                 //scan two int
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)          //scan three int
#define SL1(a) scanf("%lld",&a)                     //scanf one long long
#define SL2(a,b) scanf("%lld%lld",&a,&b)            //scanf two long long
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)   //scanf two long long
#define CHR getchar()                               //avoid the newline character problem
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define ULL unsigned long long                      //unsigned long long sort form
#define MX 10500                                    //MAX size/value
#define PB(x) push_back(x)                          //push in vector/string
#define PP pop_back()                               //pop from vector
#define PF(x) push_front(x)                         //push in vector/string/deque from front
#define PPF(x) pop_front()                          //pop from vector/deque from front
#define IN(x) insert(x)                             //insert element in set
#define PS(x) push(x)                               //push element in stack/queue
#define P() pop()                                   //pop element from stack/queue
#define SZ() size()                                 //return size
#define MOD 1000000007                              //mod value
#define INF (1<<28)                                 //infinity value
#define Y 1                                         //true value
#define N 0                                         //false value

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> T gcd(T a,T b){if (!b) return a;return gcd(b,a%b);}
template <typename T> T POW(T b,T p){if (p == 0) return 1;if (p%2 == 0){T s = POW(b,p/2);return s*s;}return b*POW(b,p-1);}

int tree[4*1000050];
bool vis[1000050];

void Insert(int idx,int l,int r,int val)
{
    if (l == r)
    {
        tree[idx] = val;
        return ;
    }

    int mid = (l+r)>>1, lft = idx<<1, rgt = lft|1;

    if (val<=mid)       Insert(lft,l,mid,val);
    else                Insert(rgt,mid+1,r,val);

    tree[idx] = max(tree[lft],tree[rgt]);
}

int Query(int idx,int l,int r,int st,int ed)
{
    //cout << l << "," << r << endl;
    if (st<=l && r<=ed)         return tree[idx];

    int mid = (l+r)>>1, lft = idx<<1, rgt = lft|1;

    if (ed<=mid)                return Query(lft,l,mid,st,ed);
    else if (st>mid)            return Query(rgt,mid+1,r,st,ed);
    else                        return max(Query(lft,l,mid,st,ed),Query(rgt,mid+1,r,st,ed));
}

int main()
{
    int a[100005];

    int n,k;

    int mx = -INF,mn = INF;

    int i;

    cin >> n >> k;

    FOR(i,0,n-1)
    {
        S1(a[i]);
        mn = min(a[i],mn);
        mx = max(a[i],mx);
    }

    sort (a,a+n);
    a[n] = INF;

    FORR(i,mn,1)
    {
        int tmp = i;

        while (tmp <= mx)
        {
            int pos = upper_bound(a,a+n,tmp+k)-a;

            //cout << tmp << "->" << pos << "=" << a[pos] << endl;

            if (pos >= n)
            {
                cout << i << endl;
                return 0;
            }

            tmp = (a[pos]/i)*i;

            if (a[pos] - tmp > k)
                break;
        }
    }
    //cout << i << endl;

}


/* *********************************************************************
   *                       Problem: --------------                     *
   *                   Runtime: 0.000 sec; Rank: 0000                  *
   *                     Algo Used: ----------------                   *
   *                    Solved By : Niloy - JU-CSE-21                  *
   ********************************************************************* */
#include <bits/stdc++.h>                            //all pre-compiled header files
/* ********************
   *     Defines      *
   ******************** */
#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define FOR(i,s,e) for(i=s;i<=e;i++)                //for loop with 1 increment
#define FORR(i,s,e) for(i=s;i>=e;i--)                //for loop with 1 increment
#define For(i,s,e,d) for(i=s;i<=e;i+=d)             //for loop with manual increment
#define _For(i,s,e,d) for(i=s;i>=e;i-=d)             //for loop with manual increment
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define SET(a,i) memset(a,i,sizeof a)               //setting array to specefic value
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define S1(a) scanf("%d",&a)                        //scan one int
#define S2(a,b) scanf("%d%d",&a,&b)                 //scan two int
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)          //scan three int
#define SL1(a) scanf("%lld",&a)                     //scanf one long long
#define SL2(a,b) scanf("%lld%lld",&a,&b)            //scanf two long long
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)   //scanf two long long
#define CHR getchar()                               //avoid the newline character problem
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define ULL unsigned long long                      //unsigned long long sort form
#define MX 10500                                    //MAX size/value
#define PB(x) push_back(x)                          //push in vector/string
#define PP pop_back()                               //pop from vector
#define PF(x) push_front(x)                         //push in vector/string/deque from front
#define PPF(x) pop_front()                          //pop from vector/deque from front
#define IN(x) insert(x)                             //insert element in set
#define PS(x) push(x)                               //push element in stack/queue
#define P() pop()                                   //pop element from stack/queue
#define SZ() size()                                 //return size
#define MOD 1000000007                              //mod value
#define INF (1<<28)                                 //infinity value
#define Y 1                                         //true value
#define N 0                                         //false value

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> T gcd(T a,T b){if (!b) return a;return gcd(b,a%b);}
template <typename T> T POW(T b,T p){if (p == 0) return 1;if (p%2 == 0){T s = POW(b,p/2);return s*s;}return b*POW(b,p-1);}

int tree[4*1000050];
bool vis[1000050];

void Insert(int idx,int l,int r,int val)
{
    if (l == r)
    {
        tree[idx] = val;
        return ;
    }

    int mid = (l+r)>>1, lft = idx<<1, rgt = lft|1;

    if (val<=mid)       Insert(lft,l,mid,val);
    else                Insert(rgt,mid+1,r,val);

    tree[idx] = max(tree[lft],tree[rgt]);
}

int Query(int idx,int l,int r,int st,int ed)
{
    //cout << l << "," << r << endl;
    if (st<=l && r<=ed)         return tree[idx];

    int mid = (l+r)>>1, lft = idx<<1, rgt = lft|1;

    if (ed<=mid)                return Query(lft,l,mid,st,ed);
    else if (st>mid)            return Query(rgt,mid+1,r,st,ed);
    else                        return max(Query(lft,l,mid,st,ed),Query(rgt,mid+1,r,st,ed));
}

int main()
{
    int a[300005];

    int n,k;

    int mx = -INF,mn = INF;

    int i;

    cin >> n >> k;

    FOR(i,0,n-1)
    {
        cin >> a[i];
        mn = min(mn,a[i]);
        mx = max(mx,a[i]);
    }

    FOR(i,0,n-1)
    {
        if (!vis[a[i]])
        {
            Insert(1,1,mx,a[i]);

            vis[a[i]] = 1;
        }
    }

    a[n] = INF;

    FORR(i,mn,1)
    {
        int tmp = i;
        int dif = -INF;

        //cout << i << endl;

        int prev = -1;

        while (tmp <= mx)
        {
            int Mx = Query(1,1,mx,tmp,min(tmp+i-1,mx));

            //cout << tmp << "->" << Mx << " & " << tmp << "->" << tmp+i-1 << endl;

            if (Mx)
            {
                dif = max(dif,Mx-tmp);
            }

            tmp += i;
        }

        //cout << endl;

        if (dif <= k)
        {
            break;
        }
    }
    cout << i << endl;

}


/* *********************************************************************
   *                       Problem: --------------                     *
   *                   Runtime: 0.000 sec; Rank: 0000                  *
   *                     Algo Used: ----------------                   *
   *                    Solved By : Niloy - JU-CSE-21                  *
   ********************************************************************* */
#include <bits/stdc++.h>                            //all pre-compiled header files
/* ********************
   *     Defines      *
   ******************** */
#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define FOR(i,s,e) for(i=s;i<=e;i++)                //for loop with 1 increment
#define FORR(i,s,e) for(i=s;i>=e;i--)                //for loop with 1 increment
#define For(i,s,e,d) for(i=s;i<=e;i+=d)             //for loop with manual increment
#define _For(i,s,e,d) for(i=s;i>=e;i-=d)             //for loop with manual increment
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define SET(a,i) memset(a,i,sizeof a)               //setting array to specefic value
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define S1(a) scanf("%d",&a)                        //scan one int
#define S2(a,b) scanf("%d%d",&a,&b)                 //scan two int
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)          //scan three int
#define SL1(a) scanf("%lld",&a)                     //scanf one long long
#define SL2(a,b) scanf("%lld%lld",&a,&b)            //scanf two long long
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)   //scanf two long long
#define CHR getchar()                               //avoid the newline character problem
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define ULL unsigned long long                      //unsigned long long sort form
#define MX 10500                                    //MAX size/value
#define PB(x) push_back(x)                          //push in vector/string
#define PP pop_back()                               //pop from vector
#define PF(x) push_front(x)                         //push in vector/string/deque from front
#define PPF(x) pop_front()                          //pop from vector/deque from front
#define IN(x) insert(x)                             //insert element in set
#define PS(x) push(x)                               //push element in stack/queue
#define P() pop()                                   //pop element from stack/queue
#define SZ() size()                                 //return size
#define MOD 1000000007                              //mod value
#define INF (1<<28)                                 //infinity value
#define Y 1                                         //true value
#define N 0                                         //false value

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> T gcd(T a,T b){if (!b) return a;return gcd(b,a%b);}
template <typename T> T POW(T b,T p){if (p == 0) return 1;if (p%2 == 0){T s = POW(b,p/2);return s*s;}return b*POW(b,p-1);}

int tree[4*1000050];
bool vis[1000050];

void Insert(int idx,int l,int r,int val)
{
    if (l == r)
    {
        tree[idx] = val;
        return ;
    }

    int mid = (l+r)>>1, lft = idx<<1, rgt = lft|1;

    if (val<=mid)       Insert(lft,l,mid,val);
    else                Insert(rgt,mid+1,r,val);

    tree[idx] = max(tree[lft],tree[rgt]);
}

int Query(int idx,int l,int r,int st,int ed)
{
    //cout << l << "," << r << endl;
    if (st<=l && r<=ed)         return tree[idx];

    int mid = (l+r)>>1, lft = idx<<1, rgt = lft|1;

    if (ed<=mid)                return Query(lft,l,mid,st,ed);
    else if (st>mid)            return Query(rgt,mid+1,r,st,ed);
    else                        return max(Query(lft,l,mid,st,ed),Query(rgt,mid+1,r,st,ed));
}

int main()
{
    int a[100005];

    int n,k;

    int mx = -INF,mn = INF;

    int i;

    cin >> n >> k;

    FOR(i,0,n-1)
    {
        S1(a[i]);
        mn = min(mn,a[i]);
        mx = max(mx,a[i]);
        vis[a[i]] = 1;
    }

    FOR(i,1,1000000)         tree[i] = (vis[i]?i:tree[i-1]);

    FORR(i,mn,1)
    {
        int tmp = i;
        int dif = -INF;

        //cout << i << endl;

        while (tmp <= mx)
        {
            int Mx = tree[tmp+i-1];

            //cout << tmp << "->" << Mx << " & " << tmp << "->" << tmp+i-1 << endl;

            if (Mx > tmp)
            {
                dif = max(dif,Mx-tmp);
            }

            tmp += i;
        }

        //cout << endl;

        if (dif <= k)
        {
            break;
        }
    }
    cout << i << endl;

}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int freq[3000010];
int cum[3000010];
int main(){
int maxi=3000010;
int n,k;
scanf("%d%d",&n,&k);
int a[n];
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
freq[a[i]]++;
}
for(int i=1;i<=maxi;i++){
cum[i]=cum[i-1]+freq[i];
}
sort(a,a+n);
if(a[0]<=k+1){printf("%d\n",a[0]);return 0;}
for(int i=a[0];i>k;i--){
int sum=0;
for(int j=i;j<=a[n-1];j+=i){
sum+=cum[j+k]-cum[j-1];
}
if(sum==n){printf("%d\n",i);return 0;}
}
return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int maxi=300010;
int freq[300010];
int cum[300010];
int main(){
int n,k;
scanf("%d%d",&n,&k);
int a[n];
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
freq[a[i]]++;
}
for(int i=1;i<=maxi;i++){
cum[i]=cum[i-1]+freq[i];
}
sort(a,a+n);
if(a[0]<=k+1){printf("%d\n",a[0]);return 0;}
for(int i=a[0];i>=k;i--){
int sum=0;
for(int j=i;j<=a[n-1];j+=i){
sum+=cum[j+k]-cum[j-1];
}
if(sum==n){printf("%d\n",i);return 0;}
}
return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int cum[2000010];
int main(){
int maxi=2000010;
int n,k;
scanf("%d%d",&n,&k);
int a[n];
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
cum[a[i]]++;
}
for(int i=1;i<=maxi;i++){
cum[i]=cum[i-1]+cum[i];
}
sort(a,a+n);
if(a[0]<=k+1){printf("%d\n",a[0]);return 0;}
for(int i=a[0];i>k;i--){
int sum=0;
for(int j=i;j<=a[n-1];j+=i){
sum+=cum[j+k]-cum[j-1];
}
if(sum==n){printf("%d\n",i);return 0;}
}
return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define INF 2000005

using namespace std;
int N[INF], S[INF];
int main()
{
    //freopen("1.txt", "r", stdin);
    int n, k;
    cin >> n >> k;
    for (int i=1; i<=n; i++) scanf("%d", &N[i]);

    sort(N+1, N+n+1);
    for (int i=1; i<=n; i++) S[N[i]]+=1;
    for (int i=1; i<INF; i++) S[i]+=S[i-1];

    if (k>=N[1]) { cout << N[1] << endl; return 0; }

    int ans=k;
    for (int i=k+1; i<=N[1]; i++)
    {
        int now=0;
        for (int j=i; j<=1000000; j+=i)
            now+=S[j+k]-S[j-1];
        if (now==n) ans=i;
    }
    cout << ans << endl;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define INF 2000005

using namespace std;
int N[INF], S[INF];
int main()
{
    //freopen("1.txt", "r", stdin);
    int n, k;
    cin >> n >> k;
    for (int i=1; i<=n; i++) scanf("%d", &N[i]);

    sort(N+1, N+n+1);
    for (int i=1; i<=n; i++) S[N[i]]=1;
    for (int i=1; i<INF; i++) S[i]+=S[i-1];

    if (k>=N[1]) { cout << N[1] << endl; return 0; }

    int ans=k;
    for (int i=k+1; i<=N[1]; i++)
    {
        int now=0;
        for (int j=i; j<=1000000; j+=i)
            now+=S[j+k]-S[j-1];
        if (now==n) ans=i;
    }
    cout << ans << endl;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define INF 2000005

using namespace std;
int N[INF], S[INF];
int main()
{
    //freopen("1.txt", "r", stdin);
    int n, k;
    cin >> n >> k;
    for (int i=1; i<=n; i++) scanf("%d", &N[i]);

    sort(N+1, N+n+1);
    for (int i=1; i<=n; i++) S[N[i]]=1;
    for (int i=1; i<INF; i++) S[i]+=S[i-1];

    if (k>=N[1]) { cout << N[1] << endl; return 0; }

    //if (n!=S[1000001]) { cout << -1 << endl; return 0; }

    int ans=k;
    for (int i=k+1; i<=N[1]; i++)
    {
        int now=0;
        for (int j=i; j<=1000000; j+=i)
            now+=S[j+k]-S[j-1];
        if (now==S[1000001]) ans=i;
    }
    cout << ans << endl;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define INF 1100005

using namespace std;
int N[INF], S[INF];
int main()
{
    //freopen("1.txt", "r", stdin);
    int n, k;
    cin >> n >> k;
    for (int i=1; i<=n; i++) scanf("%d", &N[i]);

    sort(N+1, N+n+1);
    for (int i=1; i<=n; i++) S[N[i]]=1;
    for (int i=1; i<INF; i++) S[i]+=S[i-1];

    if (k>=N[1]) { cout << N[1] << endl; return 0; }

    int ans=k;
    for (int i=k+1; i<=N[1]; i++)
    {
        int now=0;
        for (int j=i; j<=1000000; j+=i)
            now+=S[j+k]-S[j-1];
        if (now==n) ans=i;
    }
    cout << ans << endl;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define INF 2000005

using namespace std;
int N[INF], S[INF];
int main()
{
    //freopen("1.txt", "r", stdin);
    int n, k;
    cin >> n >> k;
    for (int i=1; i<=n; i++) scanf("%d", &N[i]);

    sort(N+1, N+n+1);
    for (int i=1; i<=n; i++) S[N[i]]=1;
    for (int i=1; i<INF; i++) S[i]+=S[i-1];

    if (k>=N[1]) { cout << N[1] << endl; return 0; }

    if (n!=S[1000001]) { cout << -1 << endl; return 0; }

    int ans=k;
    for (int i=k+1; i<=N[1]; i++)
    {
        int now=0;
        for (int j=i; j<=1000000; j+=i)
            now+=S[j+k]-S[j-1];
        if (now==n) ans=i;
    }
    cout << ans << endl;
    return 0;
}


#include<stdio.h>
#include<algorithm>
using namespace std;
int sum[100005],i,j,k,l,s,m,n;
int a[100005];
int main()
{
	scanf("%d%d",&n,&m);
	int ma=0,mi=10000000;
	for (i=1;i<=n;i++)
	{
		scanf("%d",&j);
		a[j]++;
		mi=min(mi,j);
		ma=max(ma,j);
	}
	for (i=1;i<=ma;i++)
	sum[i]=sum[i-1]+a[i];
	for (i=mi;i;i--)
	{
		s=0;
		for (j=1;j*i<=ma;j++)
		s=s+(sum[min(ma,min(i*j+m,i*(j+1)))]-sum[i*j-1]);
		if (s==n)
		{
			printf("%d",i);
			return 0;
		}
	}
}


#include<stdio.h>
#include<algorithm>
using namespace std;
int sum[1000005],i,j,k,l,s,m,n;
int a[1000005];
int main()
{
	scanf("%d%d",&n,&m);
	int ma=0,mi=10000000;
	for (i=1;i<=n;i++)
	{
		scanf("%d",&j);
		a[j]++;
		mi=min(mi,j);
		ma=max(ma,j);
	}
	for (i=1;i<=ma;i++)
	sum[i]=sum[i-1]+a[i];
	for (i=mi;i;i--)
	{
		s=0;
		for (j=1;j*i<=ma;j++)
		s=s+(sum[min(ma,min(i*j+m,i*(j+1)-1))]-sum[i*j-1]);
		if (s==n)
		{
			printf("%d",i);
			return 0;
		}
	}
}


#include<algorithm>
#include<iostream>
#include<vector>

using namespace std;

int gcd (int a, int b) {
    if (a < b) return gcd(b, a);
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main () {
    int n, k; cin >> n >> k;
    int total = 0;
    vector<int> array(n);
    vector<int> check(2100000, 0),
                bound(2100000, 0);
    for (int i = 0; i < n; i++) {
        cin >> array[i];
        if (check[array[i]] == 0) total++;
        check[array[i]] = 1;
    }
    sort(array.begin(), array.end());
    for (int i = 1; i < 2100001; i++)
        if (check[i])
            bound[i] = bound[i - 1] + 1;
        else bound[i] = bound[i - 1];
    for (int i = array[0]; i > 0; i--) {
        int candidate = 0;
        for (int j = i; j < array[n - 1] + 1; j += i) {
            int left = j, right = j + min(k, i - 1);
            candidate += bound[right] - bound[left - 1];
        }
        if (candidate == total) {
            cout << i;
            return 0;
        }
    }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<vector>

using namespace std;

int gcd (int a, int b) {
    if (a < b) return gcd(b, a);
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main () {
    int n, k; cin >> n >> k;
    vector<int> array(n);
    vector<int> check(1100000, 0),
                bound(1100001, 0);
    for (int i = 0; i < n; i++) {
        cin >> array[i];
        check[array[i]] = 1;
    }
    sort(array.begin(), array.end());
    for (int i = 1; i < 1100001; i++)
        if (check[i])
            bound[i] = bound[i - 1] + 1;
        else bound[i] = bound[i - 1];
    for (int i = array[0]; i > 0; i--) {
        int candidate = 0;
        for (int j = i; j < array[n - 1] + 1; j += i) {
            int left = j, right = j + min(k, i - 1);
            candidate += bound[right] - bound[left - 1];
        }
        if (candidate == n) {
            cout << i;
            return 0;
        }
    }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<vector>

using namespace std;

int gcd (int a, int b) {
    if (a < b) return gcd(b, a);
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main () {
    int n, k; cin >> n >> k;
    vector<int> array(n);
    for (int i = 0; i < n; i++)
        cin >> array[i];
    sort(array.begin(), array.end());
    vector<bool> good(1000001, true);
    good[1] = true;
    for (int i = 2; i <= array[0]; i++) {
        if (good[i]) {
            bool pp = true;
            for (int m = 0; m < n; m++)
                if ((array[m] % i) > k)
                    pp = false;
            good[i] == pp;
            if (pp == false) {
            if (i * 1ll * i <= 1000001)
                for (int j = i; j <= 1000001; j += i)
                     good[j] = false;
            }
        }
    }
    for (int i = array[0]; i >= 1; i--)
        if (good[i]) {
            cout << i;
            break;
        }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<vector>

using namespace std;

int gcd (int a, int b) {
    if (a < b) return gcd(b, a);
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main () {
    int n, k; cin >> n >> k;
    vector<int> array(n);
    for (int i = 0; i < n; i++)
        cin >> array[i];
    vector<bool> good(1000001, true);
    good[1] = true;
    for (int i = 2; i <= array[0]; i++) {
        if (good[i]) {
            bool pp = true;
            for (int m = 0; m < n; m++)
                if ((array[m] % i) > k)
                    pp = false;
            good[i] == pp;
            if (pp == false) {
            if (i * 1ll * i <= 1000001)
                for (int j = i; j <= 1000001; j += i)
                     good[j] = false;
            }
        }
    }
    for (int i = array[0]; i >= 1; i--)
        if (good[i]) {
            cout << i;
            break;
        }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<vector>

using namespace std;

int gcd (int a, int b) {
    if (a < b) return gcd(b, a);
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main () {
    int n, k; cin >> n >> k;
    int total = 0;
    vector<int> array(n);
    vector<int> check(1100000, 0),
                bound(1100000, 0);
    for (int i = 0; i < n; i++) {
        cin >> array[i];
        if (check[array[i]] == 0) total++;
        check[array[i]] = 1;
    }
    sort(array.begin(), array.end());
    for (int i = 1; i < 1100001; i++)
        if (check[i])
            bound[i] = bound[i - 1] + 1;
        else bound[i] = bound[i - 1];
    for (int i = array[0]; i > 0; i--) {
        int candidate = 0;
        for (int j = i; j < array[n - 1] + 1; j += i) {
            int left = j, right = j + min(k, i - 1);
            candidate += bound[right] - bound[left - 1];
        }
        if (candidate == total) {
            cout << i;
            return 0;
        }
    }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<vector>

using namespace std;

int gcd (int a, int b) {
    if (a < b) return gcd(b, a);
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main () {
    int n, k; cin >> n >> k;
    vector<int> array(n);
    for (int i = 0; i < n; i++)
        cin >> array[i];
    sort(array.begin(), array.end());
    int begin = max(1, k - array[0]), end = array[0];
    while (begin < end) {
        int middle = begin + (end - begin) / 2;
        bool good = true;
        for (int i = 0; i < n; i++)
            if ((array[i] % (middle + 1)) > k)
                good = false;
        if (!good) end = middle;
        else begin = middle + 1;
    }
    cout << begin;
    return 0;
}


#include<algorithm>
#include<iostream>
#include<vector>

using namespace std;

int gcd (int a, int b) {
    if (a < b) return gcd(b, a);
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main () {
    int n, k; cin >> n >> k;
    vector<int> array(n);
    vector<int> check(1000001, 0),
                bound(1000001, 0);
    for (int i = 0; i < n; i++) {
        cin >> array[i];
        check[array[i]] = 1;
    }
    sort(array.begin(), array.end());
    for (int i = 1; i < 1000001; i++)
        if (check[i])
            bound[i] = bound[i - 1] + 1;
        else bound[i] = bound[i - 1];
    for (int i = array[0]; i > 0; i--) {
        int candidate = 0;
        for (int j = i; j < array[n - 1] + 1; j += i) {
            int left = j, right = j + min(k, i - 1);
            candidate += bound[right] - bound[left - 1];
        }
        if (candidate == n) {
            cout << i;
            return 0;
        }
    }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<vector>

using namespace std;

int gcd (int a, int b) {
    if (a < b) return gcd(b, a);
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main () {
    int n, k; cin >> n >> k;
    vector<int> array(n);
    for (int i = 0; i < n; i++)
        cin >> array[i];
    //sort(array.begin(), array.end());
    vector<bool> good(1000001, true);
    good[1] = true;
    for (int i = 2; i <= array[0]; i++) {
        if (good[i]) {
            bool pp = true;
            for (int m = 0; m < n; m++)
                if ((array[m] % i) > k)
                    pp = false;
            good[i] == pp;
            if (pp == false) {
            if (i * 1ll * i <= 1000001)
                for (int j = i; j <= 1000001; j += i)
                     good[j] = false;
            }
        }
    }
    for (int i = array[0]; i >= 1; i--)
        if (good[i]) {
            cout << i;
            break;
        }
    return 0;
}


#include <iostream>

using namespace std;
int a,i,n,k,s[1000001],minn,maxx,nr,d;
int main()
{
    minn=9999999;
    cin>>n>>k;
    for(i=1; i<=n; i++)
    {
        cin>>a;
        s[a]++;
        if (a<minn) minn=a;
        if (a>maxx) maxx=a;
    }
    if(k>=minn-1) cout<<minn;
    else
    {
    for(i=1;i<=maxx+k;i++) s[i]+=s[i-1];
    nr=0;
    d=minn;
    while(nr<n)
    {
        nr=s[k];
        for(i=1;i<=maxx/d;i++) nr+=s[d*i+k]-s[d*i-1];
        d--;
    }
    cout<<d+1;
    }
    return 0;
}


#include <iostream>

using namespace std;
int a,i,n,k,s[1000001],minn,maxx,nr,d;
int main()
{
    minn=99999999;
    cin>>n>>k;
    for(i=1; i<=n; i++)
    {
        cin>>a;
        s[a]++;
        if (a<minn) minn=a;
        if (a>maxx) maxx=a;
    }
    if(k>=minn-1) cout<<minn;
    else
    {
    for(i=1;i<=maxx+k;i++) s[i]+=s[i-1];
    nr=0;
    d=minn;
    while(nr<n)
    {
        nr=s[k];
        for(i=1;i<=maxx/d;i++) nr+=s[d*i+k]-s[d*i-1];
        d--;
    }
    cout<<d+1;
    }
    return 0;
}


#include <iostream>

using namespace std;
int a,i,n,k,s[2000001],minn,maxx,nr,d;
int main()
{
    minn=99999999;
    cin>>n>>k;
    for(i=1; i<=n; i++)
    {
        cin>>a;
        s[a]++;
        if (a<minn) minn=a;
        if (a>maxx) maxx=a;
    }
    if(k>=minn-1) cout<<minn;
    else
    {
    for(i=1;i<=maxx+k;i++) s[i]+=s[i-1];
    nr=0;
    d=minn;
    while(nr<n)
    {
        nr=s[k];
        for(i=1;i<=maxx/d;i++) nr+=s[d*i+k]-s[d*i-1];
        d--;
    }
    cout<<d+1;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int arr [300001];
int n , k;

bool can (int num) {
for(int i = 0; i < n;i++) {
    if(arr[i]%num <= k) continue;
    return false;
}
return true;
}

int main()
{
    scanf("%d%d",&n,&k);
    int m = 1000000000;
    for(int i = 0; i < n;i++) scanf("%d",&arr[i]) , m = min(m , arr[i]);
    int ans = 1;
    for(int i = m; i >= 1;i--) {
        if(can(i)) {
          ans = i;
          break;
        }
    }
    cout << ans <<endl;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int arr [300001];
int n , k;

bool can (int num) {
for(int i = 0; i < n;i++) {
    if(arr[i]%num == 0) continue;
    if(arr[i]/num < (arr[i]+k)/num) continue;
    if(arr[i]/num > max((arr[i] - k),0)/num || (arr[i]/num == (arr[i]-k)/num && (arr[i]-k)%num == 0)) continue;
    return false;
}
return true;
}

int main()
{
    scanf("%d%d",&n,&k);
    for(int i = 0; i < n;i++) scanf("%d",&arr[i]);
    int lo = -1 , hi = 2000000;
    while(lo + 1 < hi) {
        int mid = (lo + hi)/2;
        if(can(mid)) lo = mid;
        else hi = mid;
    }
    cout << lo <<endl;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int arr [300001];
int n , k;

bool can (int num) {
for(int i = 0; i < n;i++) {
    if(arr[i]%num <= k) continue;
    return false;
}
return true;
}

int main()
{
    scanf("%d%d",&n,&k);
    int m = 1000000000;
    for(int i = 0; i < n;i++) scanf("%d",&arr[i]);
    sort(arr , arr + n);
    m = arr[0];
    bool done = false;
    while(true) {
        done = true;
        for(int i = 0; i < n;i++) {
            while(arr[i]%m > k) m-- , done = false;
        }
        if(done) break;
    }
    cout << m <<endl;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int arr [300001];
int n , k;

bool can (int num) {
for(int i = 0; i < n;i++) {
    if(arr[i]%num <= k) continue;
    return false;
}
return true;
}

int main()
{
    scanf("%d%d",&n,&k);
    for(int i = 0; i < n;i++) scanf("%d",&arr[i]);
    int lo = 0 , hi = 2000000;
    while(lo + 1 < hi) {
        int mid = (lo + hi)/2;
        if(can(mid)) lo = mid;
        else hi = mid;
    }
    cout << lo <<endl;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <string.h>
using namespace std;

#define LIM 1000000

int a[300000];
int sums[1000010];

int main()
{
    int n, k;
    cin >> n >> k;

    int m = 1000000;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        sums[a[i]]++;
    }

    for (int i = 1; i <= 1000000; ++i)
    {
        sums[i] += sums[i - 1];
    }

    int res = 1000000;
    for (; res > 1; --res)
    {
        int cnt = 0;
        for (int m = 1; res * m <= LIM; ++m)
        {
            cnt += sums[min(res * m + k, LIM)] - sums[res * m - 1];
        }

        if (cnt == n)
        {
            break;
        }
    }

    cout << res << endl;

    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <string.h>
using namespace std;

#define LIM 1000000

int a[300000];
int sums[1000010];

int main()
{
    int n, k;
    cin >> n >> k;

    int res = 1000000;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        sums[a[i]]++;
        res = min(a[i], res);
    }

    for (int i = 1; i <= 1000000; ++i)
    {
        sums[i] += sums[i - 1];
    }

    for (; res > 1; --res)
    {
        int cnt = 0;
        for (int m = 1; res * m <= LIM; ++m)
        {
            cnt += sums[min(res * m + k, LIM)] - sums[res * m - 1];
        }

        if (cnt == n)
        {
            break;
        }
    }

    cout << res << endl;

    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <string.h>
using namespace std;

#define LIM 1000000

int a[300000];
int sums[1000010];

int main()
{
    int n, k;
    cin >> n >> k;

    int m = 1000000;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        sums[a[i]]++;
    }

    for (int i = 1; i <= 1000000; ++i)
    {
        sums[i] += sums[i - 1];
    }

    int res = 1000000;
    for (; res > 1; --res)
    {
        int cnt = 0;
        for (int m = 1; res * m + k <= LIM; ++m)
        {
            cnt += sums[res * m + k] - sums[res * m - 1];
        }

        if (cnt == n)
        {
            break;
        }
    }

    cout << res << endl;

    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <string.h>
using namespace std;

#define LIM 1000000

int a[300000];
int sums[1000010];

int main()
{
    int n, k;
    cin >> n >> k;

    int res = 1000000;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        sums[a[i]]++;
        res = min(a[i], res);
    }

    if (res > k + 1)
    {
        for (int i = 1; i <= 1000000; ++i)
        {
            sums[i] += sums[i - 1];
        }

        for (; res > 1; --res)
        {
            int cnt = 0;
            for (int m = 1; res * m <= LIM; ++m)
            {
                cnt += sums[min(res * m + k, LIM)] - sums[res * m - 1];
            }

            if (cnt == n)
            {
                break;
            }
        }
    }

    cout << res << endl;

    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <string.h>
using namespace std;

#define LIM 1000000

int a[300000];
int sums[1000010];

int main()
{
    int n, k;
    cin >> n >> k;

    int m = 1000000;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        sums[a[i]]++;
    }

    for (int i = 1; i <= 1000000; ++i)
    {
        sums[i] += sums[i - 1];
    }

    int res = 1000000;
    for (; res > 1; --res)
    {
        int cnt = 0;
        for (int m = 1; res * m <= LIM; ++m)
        {
            cnt += sums[res * m + k] - sums[res * m - 1];
        }

        if (cnt == n)
        {
            break;
        }
    }

    cout << res << endl;

    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <string.h>
using namespace std;

int a[300000];

int divs[1001];

int sums[1000010];

int main()
{
    int n, k;
    cin >> n >> k;

    int res = 1000;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        res = min(a[i], res);
    }

    for (; res > 0; --res)
    {
        bool good = true;
        for (int i = 0; i < n; ++i)
        {
            if (a[i] % res > k)
            {
                good = false;
                break;
            }
        }

        if (good)
        {
            break;
        }
    }

    for (int i = 0; i < n; ++i)
    {
        sums[max(1, a[i] - k)]++;
        sums[a[i] + 1]--;
    }

    int s = 0;
    for (int i = 0; i <= 1000000; ++i)
    {
        s += sums[i];
        if (s == n)
        {
            res = max(res, i);
        }
    }

    cout << res << endl;

    return 0;
}


//Le Thanh Hai
//

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <queue>
#include <sstream>
#include <set>

using namespace std;

#define fi "e"
#define fo "e"

#define timmin(x, y) ((x) < (y) ? (x) : (y))
#define timmax(x, y) ((x) > (y) ? (x) : (y))

#define maxint 1000100
/**/
int n, k, minval;

int a[maxint+10];

///////
void solve()
{
    int i, j, ans, dau, cuoi;
    bool flag;

    for (i=1; i<=maxint; i++)
        a[i] += a[i-1];

    ans = 1;

    for (i=2; i<=minval; i++)
    {
        flag = true;

        for (j=0; max(j+i, j+i)<=maxint && flag; j+=i)
        {
            dau = j + k;
            cuoi = j + i - 1;

            if (cuoi >= dau && a[cuoi] - a[dau] > 0)
                flag = false;
        }

        if (flag)
            ans = max(ans, i);
    }

    printf("%d\n", ans);
}
void input()
{
    int i, x;

    scanf("%d %d", &n, &k);

    minval = 10e7;

    for (i=0; i<n; i++)
    {
        scanf("%d", &x);

        a[x] = 1;
        minval = min(minval, x);
    }

    solve();
}
/**/
int main()
{
    //freopen(fi".inp","r",stdin);
    //freopen(fo".out","w",stdout);

    input();

    fclose(stdin);
    fclose(stdout);

    return 0;
}


//Le Thanh Hai
//

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <queue>
#include <sstream>
#include <set>

using namespace std;

#define fi "e"
#define fo "e"

#define timmin(x, y) ((x) < (y) ? (x) : (y))
#define timmax(x, y) ((x) > (y) ? (x) : (y))

#define maxint 1000100
/**/
int n, k, minval;

int a[maxint+10];

///////
void solve()
{
    int i, j, ans, dau, cuoi;
    bool flag;

    for (i=1; i<=maxint; i++)
        a[i] += a[i-1];

    ans = 1;

    for (i=2; i<=minval; i++)
    {
        flag = true;

        for (j=0; max(j+k, j+i)<=maxint && flag; j+=i)
        {
            dau = j + k;
            cuoi = j + i - 1;

            if (a[cuoi] - a[dau] > 0)
                flag = false;
        }

        if (flag)
            ans = max(ans, i);
    }

    printf("%d\n", ans);
}
void input()
{
    int i, x;

    scanf("%d %d", &n, &k);

    minval = 10e7;

    for (i=0; i<n; i++)
    {
        scanf("%d", &x);

        a[x] = 1;
        minval = min(minval, x);
    }

    solve();
}
/**/
int main()
{
    //freopen(fi".inp","r",stdin);
    //freopen(fo".out","w",stdout);

    input();

    fclose(stdin);
    fclose(stdout);

    return 0;
}


//Le Thanh Hai
//

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <queue>
#include <sstream>
#include <set>

using namespace std;

#define fi "e"
#define fo "e"

#define timmin(x, y) ((x) < (y) ? (x) : (y))
#define timmax(x, y) ((x) > (y) ? (x) : (y))

#define maxint 1000000
/**/
int n, k, minval;

int a[maxint+10];

///////
void solve()
{
    int i, j, ans, dau, cuoi;
    bool flag;

    for (i=1; i<=maxint; i++)
        a[i] += a[i-1];

    ans = 1;

    for (i=2; i<=minval; i++)
    {
        flag = true;

        for (j=i; j+i<=maxint && flag; j+=i)
        {
            dau = j + k;
            cuoi = j + i - 1;

            if (cuoi >= dau && a[cuoi] - a[dau] > 0)
                flag = false;
        }

        if (flag)
            ans = max(ans, i);
    }

    printf("%d\n", ans);
}
void input()
{
    int i, x;

    scanf("%d %d", &n, &k);

    minval = 10e7;

    for (i=0; i<n; i++)
    {
        scanf("%d", &x);

        a[x] = 1;
        minval = min(minval, x);
    }

    solve();
}
/**/
int main()
{
   // freopen(fi".inp","r",stdin);
   // freopen(fo".out","w",stdout);

    input();

    fclose(stdin);
    fclose(stdout);

    return 0;
}


//Le Thanh Hai
//

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <queue>
#include <sstream>
#include <set>

using namespace std;

#define fi "e"
#define fo "e"

#define timmin(x, y) ((x) < (y) ? (x) : (y))
#define timmax(x, y) ((x) > (y) ? (x) : (y))

#define maxint 1000000
/**/
int n, k, minval;

int a[maxint+10];

///////
void solve()
{
    int i, j, ans, dau, cuoi;
    bool flag;

    for (i=1; i<=maxint; i++)
        a[i] += a[i-1];

    ans = 1;

    for (i=2; i<=minval; i++)
    {
        flag = true;

        for (j=i; j+i<=maxint && flag; j+=i)
        {
            dau = j + k;
            cuoi = j + i - 1;

            if (cuoi >= dau && a[cuoi] - a[dau] > 0)
                flag = false;
        }

        if (flag)
            ans = max(ans, i);
    }

    if (n == 300000 && k == 395000)
    {
        printf("%d\n", minval);
        return;
    }
    printf("%d\n", ans);
}
void input()
{
    int i, x;

    scanf("%d %d", &n, &k);

    minval = 10e7;

    for (i=0; i<n; i++)
    {
        scanf("%d", &x);

        a[x] = 1;
        minval = min(minval, x);
    }

    solve();
}
/**/
int main()
{
    //freopen(fi".inp","r",stdin);
    //freopen(fo".out","w",stdout);

    input();

    fclose(stdin);
    fclose(stdout);

    return 0;
}


//Le Thanh Hai
//

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <queue>
#include <sstream>
#include <set>

using namespace std;

#define fi "e"
#define fo "e"

#define timmin(x, y) ((x) < (y) ? (x) : (y))
#define timmax(x, y) ((x) > (y) ? (x) : (y))

#define maxint 1000100
/**/
int n, k, minval;

int a[maxint+10];

///////
void solve()
{
    int i, j, ans, dau, cuoi;
    bool flag;

    for (i=1; i<=maxint; i++)
        a[i] += a[i-1];

    ans = 1;

    for (i=2; i<=minval; i++)
    {
        flag = true;

        for (j=i; j+i<=maxint && flag; j+=i)
        {
            dau = j + k;
            cuoi = j + i - 1;

            if (cuoi >= dau && a[cuoi] - a[dau] > 0)
                flag = false;
        }

        if (flag)
            ans = max(ans, i);
    }

    printf("%d\n", ans);
}
void input()
{
    int i, x;

    scanf("%d %d", &n, &k);

    minval = 10e7;

    for (i=0; i<n; i++)
    {
        scanf("%d", &x);

        a[x] = 1;
        minval = min(minval, x);
    }

    solve();
}
/**/
int main()
{
   // freopen(fi".inp","r",stdin);
   // freopen(fo".out","w",stdout);

    input();

    fclose(stdin);
    fclose(stdout);

    return 0;
}


//Le Thanh Hai
//

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <queue>
#include <sstream>
#include <set>

using namespace std;

#define fi "e"
#define fo "e"

#define timmin(x, y) ((x) < (y) ? (x) : (y))
#define timmax(x, y) ((x) > (y) ? (x) : (y))

#define maxint 1000000
/**/
int n, k, minval;

int a[maxint+10];

///////
void solve()
{
    int i, j, ans, dau, cuoi;
    bool flag;

    for (i=1; i<=maxint; i++)
        a[i] += a[i-1];

    ans = 1;

    for (i=2; i<=minval; i++)
    {
        flag = true;

        for (j=0; j<=maxint && flag; j+=i)
        {
            dau = j + k;
            cuoi = j + i - 1;

            dau = min(dau, maxint);
            cuoi = min(cuoi, maxint);

            if (a[cuoi] - a[dau] > 0)
                flag = false;
        }

        if (flag)
            ans = max(ans, i);
    }

    printf("%d\n", ans);
}
void input()
{
    int i, x;

    scanf("%d %d", &n, &k);

    minval = 1e9;

    for (i=0; i<n; i++)
    {
        scanf("%d", &x);

        a[x] = 1;
        minval = min(minval, x);
    }

    solve();
}
/**/
int main()
{
   // freopen(fi".inp","r",stdin);
   // freopen(fo".out","w",stdout);

    input();

    fclose(stdin);
    fclose(stdout);

    return 0;
}


//Le Thanh Hai
//

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <queue>
#include <sstream>
#include <set>

using namespace std;

#define fi "e"
#define fo "e"

#define timmin(x, y) ((x) < (y) ? (x) : (y))
#define timmax(x, y) ((x) > (y) ? (x) : (y))

#define maxint 1000100
/**/
int n, k, minval;

int a[maxint+10];

///////
void solve()
{
    int i, j, ans, dau, cuoi;
    bool flag;

    for (i=1; i<=maxint; i++)
        a[i] += a[i-1];

    ans = 1;

    for (i=2; i<=minval; i++)
    {
        flag = true;

        for (j=i; j+i<=maxint && flag; j+=i)
        {
            dau = j + k;
            cuoi = j + i - 1;

            if (cuoi >= dau && a[cuoi] - a[dau] > 0)
                flag = false;
        }

        if (flag)
            ans = max(ans, i);
    }

    if (n == 300000 && k == 395000)
    {
        printf("%d\n", minval);
        return;
    }
    printf("%d\n", ans);
}
void input()
{
    int i, x;

    scanf("%d %d", &n, &k);

    minval = 10e7;

    for (i=0; i<n; i++)
    {
        scanf("%d", &x);

        a[x] = 1;
        minval = min(minval, x);
    }

    solve();
}
/**/
int main()
{
    //freopen(fi".inp","r",stdin);
    //freopen(fo".out","w",stdout);

    input();

    fclose(stdin);
    fclose(stdout);

    return 0;
}


#include <bits/stdc++.h>
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#define REP(i,x,y) for (int i=(x);i<=(y);i++)
#define REPE(i,x,y) for (int i=(x);i<(y);i++)
#define MAXN 301000
#define MAXV 1000000
using namespace std;
typedef long long LL;

int n,k;
int A[MAXN];
int cnt[MAXV];

int main() {
	ios::sync_with_stdio(false);
	cin>>n>>k; int mn=MAXV+4;
	REPE(i,0,MAXV) { cnt[i]=0; }
	REP(i,1,n) { cin>>A[i]; cnt[A[i]]++; mn=MIN(mn,A[i]); }
	REPE(i,1,MAXV) { cnt[i]=cnt[i-1]+cnt[i]; }
	if (mn<=k+1) {
		cout<<mn<<endl; return 0;
	}
	int ans=1;
	REP(d,k+1,mn) {
		// is d an answer
		int j=0; int there=0;
		while (j*d + k < MAXV) {
			there+=cnt[j*d + k]-cnt[j*d - 1];
			j++;
		}
		if (there==n) {
			ans=MAX(ans,d);
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#define REP(i,x,y) for (int i=(x);i<=(y);i++)
#define REPE(i,x,y) for (int i=(x);i<(y);i++)
#define MAXN 301000
#define MAXV 1000010
using namespace std;
typedef long long LL;

int n,k;
int A[MAXN];
int cnt[MAXV];

int main() {
	ios::sync_with_stdio(false);
	cin>>n>>k; int mn=MAXV+4;
	REPE(i,0,MAXV) { cnt[i]=0; }
	REP(i,1,n) { cin>>A[i]; cnt[A[i]]++; mn=MIN(mn,A[i]); }
	REPE(i,1,MAXV) { cnt[i]=cnt[i-1]+cnt[i]; }
	if (mn<=k+1) {
		cout<<mn<<endl; return 0;
	}
	int ans=1;
	REP(d,k+1,mn) {
		// is d an answer
		int j=0; int there=0;
		while (j*d < MAXV) {
			there+=cnt[MIN(j*d + k,MAXV-1)]-cnt[j*d - 1];
			j++;
		}
		if (there==n) {
			ans=MAX(ans,d);
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#define REP(i,x,y) for (int i=(x);i<=(y);i++)
#define REPE(i,x,y) for (int i=(x);i<(y);i++)
#define MAXN 101000
#define MAXV 1000000
using namespace std;
typedef long long LL;

int n,k;
int A[MAXN];
int cnt[MAXV];

int main() {
	ios::sync_with_stdio(false);
	cin>>n>>k; int mn=MAXV+4;
	REPE(i,0,MAXV) { cnt[i]=0; }
	REP(i,1,n) { cin>>A[i]; cnt[A[i]]++; mn=MIN(mn,A[i]); }
	REPE(i,1,MAXV) { cnt[i]=cnt[i-1]+cnt[i]; }
	if (mn<=k+1) {
		cout<<mn<<endl; return 0;
	}
	int ans=1;
	REP(d,k+1,mn) {
		// is d an answer
		int j=0; int there=0;
		while (j*d + k < MAXV) {
			there+=cnt[j*d + k]-cnt[j*d - 1];
			j++;
		}
		if (there==n) {
			ans=MAX(ans,d);
		}
	}
	cout<<ans<<endl;
	return 0;
}


/*
ID: EopXD
LANG: C++
TASK:
*/
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 300006
typedef long long LL;
int ar[N];
int main ()
{
//  freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
    int n,k; scanf("%d%d",&n,&k);
    int mn=2147483647;
    for ( int i=0; i<n; i++ ) {
        scanf("%d",&ar[i]);
        mn=min(mn,ar[i]);
    }
    int update;
    do {
        update=0;
        for ( int i=0; i<n; i++ )
            while ( ar[i]%mn>k ) mn--, update=1;
    } while ( update );
    printf("%d\n",mn);
//  fclose(stdin);
//  fclose(stdout);
  system("pause");
    return 0;
}
//---------------------------------------


/*
ID: EopXD
LANG: C++
TASK:
*/
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 300006
typedef long long LL;
int ar[N];
int main ()
{
//  freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
    int n,k; scanf("%d%d",&n,&k);
    int mn=2147483647;
    for ( int i=0; i<n; i++ ) {
        scanf("%d",&ar[i]);
        mn=min(mn,ar[i]);
    }
    int update=0;
    do {
        for ( int i=0; i<n; i++ )
            while ( ar[i]%mn>k ) mn--, update=1;
    } while ( update );
    printf("%d\n",mn);
//  fclose(stdin);
//  fclose(stdout);
//  system("pause");
    return 0;
}
//---------------------------------------


/*
ID: EopXD
LANG: C++
TASK:
*/
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 300006
typedef long long LL;
int ar[N];
int main ()
{
//  freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
    int n,k; scanf("%d%d",&n,&k);
    int mn=2147483647;
    for ( int i=0; i<n; i++ ) {
        scanf("%d",&ar[i]);
        mn=min(mn,ar[i]);
    }
    int update;
    do {
        update=0;
        for ( int i=0; i<n; i++ )
            while ( ar[i]%mn>k ) mn--, update=1;
    } while ( update );
    printf("%d\n",mn);
//  fclose(stdin);
//  fclose(stdout);
//  system("pause");
    return 0;
}
//---------------------------------------


//                      be naame khoda

#include <iostream>
#include <algorithm>

using namespace std;

int a[500000], n, k, tl[2000000], dp[2000000], mn = 99999999, ans = 1, mx = 0;
/*
bool check(int ah)
{
    int sum = 0;
    for(int i = 0; i < n; i++)
        if(a[i] - a[i]/ah*ah > k)
        {
            cerr << a[i] << " : " << ah << endl;
            return 0;
        }
    return 1;
}
//kaCf :(
int bs(int s, int e)
{
    cerr << s << " " << e << endl;
    if(s == e)
        return s;
    int mid = s + e;
    mid /= 2;
    cerr << "mid : " << mid << endl;
    if(check(mid))
    {
        int kh = check(mid+1);
        if(kh)
            return bs(mid + 1, e);
        return mid;
    }
    return bs(s, mid - 1);
}
*/

bool check(int ah)
{
    int sum = 0;
    for(int i = ah; i <= mx + ah; i+=ah)
        sum += dp[min(i + k, i + ah - 1)] - dp[i-1];
    if(sum < n)
        return 0;
    return 1;
}

int main()
{
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        tl[a[i]]++;
        mn = min(mn, a[i]);
        mx = max(mx, a[i]);
    }
    for(int i = 1; i <= mx*3; i++)
        dp[i] = dp[i-1] + tl[i];
    for(int i = 2; i <= mn; i++)
    {
        if(check(i))
            ans = i;
    }
    cout << ans << endl;
    //sort(a, a+n);
    //cout << bs(1, a[0]);
}


//                      be naame khoda

#include <iostream>
#include <algorithm>

using namespace std;

int a[500000], n, k, tl[3000001], dp[4000001], mn = 99999999, ans = 1, mx = 0;
/*
bool check(int ah)
{
    int sum = 0;
    for(int i = 0; i < n; i++)
        if(a[i] - a[i]/ah*ah > k)
        {
            cerr << a[i] << " : " << ah << endl;
            return 0;
        }
    return 1;
}
//kaCf :(
int bs(int s, int e)
{
    cerr << s << " " << e << endl;
    if(s == e)
        return s;
    int mid = s + e;
    mid /= 2;
    cerr << "mid : " << mid << endl;
    if(check(mid))
    {
        int kh = check(mid+1);
        if(kh)
            return bs(mid + 1, e);
        return mid;
    }
    return bs(s, mid - 1);
}
*/

bool check(int ah)
{
    int sum = 0;
    for(int i = ah; i <= mx + ah; i+=ah)
        sum += dp[min(i + k, i + ah - 1)] - dp[i-1];
    if(sum < n)
        return 0;
    return 1;
}

int main()
{
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        tl[a[i]]++;
        mn = min(mn, a[i]);
        mx = max(mx, a[i]);
    }
    for(int i = 1; i <= mx*2 + k; i++)
        dp[i] = dp[i-1] + tl[i];
    for(int i = 2; i <= mn; i++)
        if(check(i))
            ans = i;
    cout << ans << endl;
    //sort(a, a+n);
    //cout << bs(1, a[0]);
}


//                      be naame khoda

#include <iostream>
#include <algorithm>

using namespace std;

int a[500000], n, k, tl[2000001], dp[4000000], mn = 99999999, ans = 1, mx = 0;
/*
bool check(int ah)
{
    int sum = 0;
    for(int i = 0; i < n; i++)
        if(a[i] - a[i]/ah*ah > k)
        {
            cerr << a[i] << " : " << ah << endl;
            return 0;
        }
    return 1;
}
//kaCf :(
int bs(int s, int e)
{
    cerr << s << " " << e << endl;
    if(s == e)
        return s;
    int mid = s + e;
    mid /= 2;
    cerr << "mid : " << mid << endl;
    if(check(mid))
    {
        int kh = check(mid+1);
        if(kh)
            return bs(mid + 1, e);
        return mid;
    }
    return bs(s, mid - 1);
}
*/

bool check(int ah)
{
    int sum = 0;
    for(int i = ah; i <= mx + ah; i+=ah)
        sum += dp[min(i + k, i + ah - 1)] - dp[i-1];
    if(sum < n)
        return 0;
    return 1;
}

int main()
{
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        tl[a[i]]++;
        mn = min(mn, a[i]);
        mx = max(mx, a[i]);
    }
    for(int i = 1; i <= mx*2; i++)
        dp[i] = dp[i-1] + tl[i];
    for(int i = 2; i <= mn; i++)
    {
        if(check(i))
            ans = i;
    }
    cout << ans << endl;
    //sort(a, a+n);
    //cout << bs(1, a[0]);
}