#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 2, MAXIM = 1e6 + 2;
int n, k, nxt[MAXIM];
int main() {
  cin >> n >> k;
  int mn = 1e9;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    nxt[x] = x;
    mn = min(mn, x);
  }
  for (int i = 1; i < MAXIM; ++i) {
    if (nxt[i] == 0) nxt[i] = nxt[i - 1];
  }
  for (int i = mn; i > 0; --i) {
    bool bad = false;
    for (int j = i; j < MAXIM; j += i) {
      int start = j + 1, stop = min(MAXIM - 1, j + i - 1);
      if (nxt[stop] >= start && nxt[stop] - j > k) {
        bad = true;
      }
    }
    if (!bad) {
      cout << i;
      return 0;
    }
  }
}
