#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int kmpprocesser(vector<long long>& b, string s) {
  int i = 0, j = -1;
  b[0] = -1;
  while (i < s.length()) {
    while (j >= 0 && s[i] != s[j]) j = b[j];
    j++, i++;
    b[i] = j;
  }
  return j - 1;
}
int kmpsearch(string s, string ss, vector<long long> b) {
  int i = 0, j = 0;
  int cnt = 0;
  int n = s.length(), m = ss.length();
  while (i < n) {
    while (j >= 0 && ss[j] != s[i]) j = b[j];
    j++, i++;
    if (j == m) {
      cnt++, j = 0;
    }
  }
  return cnt;
}
int a[(long long)1e6 + 700], cnt[(long long)1e6 + 700];
int main() {
  int n, k;
  map<int, int> m1;
  while (cin >> n >> k) {
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    int ans = -1;
    for (int i = 0; i < (long long)1e6 + 700; i++)
      cnt[i] = lower_bound(a, a + n, i + 0.005) - a;
    if (k >= a[0] - 1) {
      cout << a[0] << endl;
      continue;
    }
    for (int l = k + 1; l <= a[0]; l++) {
      int sum = 0;
      for (int j = 1; j * l <= a[n - 1]; j++) {
        int ss;
        if (j * l + k >= a[n - 1])
          ss = n;
        else {
          ss = cnt[j * l + k];
        }
        sum += (ss - cnt[j * l - 1]);
      }
      if (sum == n) ans = l;
    }
    cout << ans << endl;
  }
}
