#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long arr[3000005];
long long k, n;
long long lb[3000005], vis[3000005];
bool chk(long long x) {
  long long mx = 0;
  if (arr[1] < x) return 0;
  for (long long i = x; i <= 1000000 + x; i += x) {
    long long cur = lb[i] - i + x;
    mx = max(mx, cur);
  }
  return mx <= k;
}
void solve() {
  long long i, j, l, r, m, a, b, c, d, x, y, z, t;
  cin >> n >> k;
  for (i = 1; i <= n; i++) cin >> arr[i], vis[arr[i]] = 1;
  for (i = 1; i <= 2000000; i++)
    if (vis[i - 1])
      lb[i] = i - 1;
    else
      lb[i] = lb[i - 1];
  sort(arr, arr + n + 1);
  long long ans = 0;
  for (i = 1; i <= 1000000; i++) {
    if (chk(i)) ans = i;
  }
  cout << ans << endl;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
