#include <bits/stdc++.h>
using namespace std;
int n, k, arr[300001], cnt[1000001 * 2];
int mi = 1000001, mx = 0;
bool check(int mid) {
  if (mid == 6) cout << "";
  ;
  int tot = 0;
  int ind = 0;
  k = min(k, mid - 1);
  while (ind <= mx) {
    tot += cnt[ind + k] - cnt[max(0, ind - 1)];
    if (tot == 2) cout << "";
    ;
    ind += mid;
  }
  return tot == n;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    cnt[arr[i]]++;
    mx = max(arr[i], mx);
    mi = min(mi, arr[i]);
  }
  for (int i = mi; i < mx + 1 + k; i++) cnt[i] += cnt[i - 1];
  for (int i = mi; i >= 2; i--)
    if (check(i)) {
      cout << i << endl;
      return 0;
    }
  cout << 1 << endl;
  return 0;
}
