#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  vector<bool> jest(2000001, false);
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    jest[x] = true;
  }
  vector<int> pref(2000001);
  if (jest[0]) pref[0] = 1;
  for (int i = 1; i < 2000001; ++i) {
    pref[i] = pref[i - 1];
    if (jest[i]) ++pref[i];
  }
  int odp = 1;
  for (int i = 2; i <= 1000000; ++i) {
    if (pref[i - 1] != 0) continue;
    if (i + k >= 2 * i)
      odp = max(odp, i);
    else {
      bool ok = true;
      for (int j = i; j <= 1000000; j += i)
        if (pref[j + k] != pref[j + i - 1]) ok = false;
      if (ok) odp = max(odp, i);
    }
  }
  cout << odp;
  return 0;
}
