#include <bits/stdc++.h>
using namespace std;
const long long M = 998244353;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long n, k;
  cin >> n >> k;
  vector<long long> A(n);
  for (long long i = 0; i < n; i++) cin >> A[i];
  sort(A.begin(), A.end());
  if (A[0] <= k + 1) {
    cout << A[0] << '\n';
    exit(0);
  }
  vector<long long> cnt(3000009);
  for (auto x : A) cnt[x]++;
  for (long long i = 1; i <= 3000005; i++) cnt[i] += cnt[i - 1];
  for (long long d = A[0]; d >= k + 1; d--) {
    bool ok = true;
    for (long long x = d; x <= 1000005 + d; x += d) {
      if (cnt[x - 1] != cnt[x - d + k]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << d << '\n';
      exit(0);
    }
  }
}
