#include <bits/stdc++.h>
using namespace std;
const long long N = 2e6 + 10;
long long cnt[N], dp[N];
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, k, mn = N, mx = 0;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    long long a;
    cin >> a;
    mn = min(a, mn);
    mx = max(a, mx);
    cnt[a]++;
  }
  if (mn <= k + 1) return cout << mn, 0;
  for (long long i = 1; i < N; i++) {
    dp[i] = dp[i - 1] + cnt[i];
  }
  for (long long i = mn; i > k + 1; i--) {
    long long Count = 0;
    for (long long b = i; b <= mx; b += i) {
      Count += dp[b + k] - dp[b - 1];
    }
    if (Count == n) return cout << i, 0;
  }
  return cout << k + 1, 0;
}
