#include <bits/stdc++.h>
using namespace std;
const int N = (int)3e5 + 5;
const int INF = (int)1e9 + 5;
const long double EPS = 1e-9;
int a[N], d[(int)2e6 + 5];
int n, k, mn, mx;
void init(int n) {
  sort(a, a + n);
  a[n] = (int)2e6 + 1;
  for (int i = 1; i < n + 1; i++)
    for (int j = a[i - 1]; j < a[i]; j++) d[j] = i;
}
inline int cnt(int l, int r) { return l == 0 ? d[r] : d[r] - d[l - 1]; }
bool check(int d) {
  int fisrt = mx / d, sum = 0;
  for (int i = 0; i <= fisrt; i++) sum += cnt(d * i, d * i + k);
  return sum == n;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  init(n);
  mn = a[0];
  mx = a[n - 1];
  if (mn <= k + 1) return cout << mn << endl, 0;
  for (int i = mn; i > k; i--)
    if (check(i)) return cout << i << endl, 0;
  return 0;
}
