#include <bits/stdc++.h>   using namespace std;   struct debugger {     template <typename T>     debugger& operator,(const T& v) {       cerr << v <<    ;       return *this;     }   } dbg;   int inf = (1 << 20);   int dp[(1 << 21) + 10];   void F(int x, int y) {     x += inf;     y += inf;     dp[x]++;     if (x == y) return;     dp[y]++;     while (x / 2 != y / 2) {       if (x % 2 == 0) dp[x + 1]++;       if (y % 2 == 1) dp[y - 1]++;       x /= 2;       y /= 2;     }     return;   }   int ar[400010];   int n, k;   int func(int x) {     int sm = 0;     x += inf;     while (x > 1) {       sm += dp[x];       x /= 2;     }     return sm;   }   int chk(int x) {     int sm = 0;     for (int i = x; i <= ar[n - 1]; i += x) sm += func(i);     if (sm == n) return 1;     return 0;   }   int main() {     cin >> n >> k;     for (int i = (0), _n = (n); i < _n; i++) cin >> ar[i];     sort(ar, ar + n);     if (ar[0] <= k) {       cout << ar[0] << endl;       return 0;     }     for (int i = (0), _n = (n); i < _n; i++) F(ar[i] - k, ar[i]);     int rs = k;     for (int i = (2), _n = (ar[0]); i <= _n; i++)       if (chk(i)) rs = i;     cout << rs << endl;     return 0;   }   