#include <bits/stdc++.h>
const int N = 1e6 + 5;
using namespace std;
int n, k, a[N], cnt[N], Min = N;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    Min = min(Min, a[i]);
    cnt[a[i]]++;
  }
  for (int i = 1; i < N; i++) cnt[i] += cnt[i - 1];
  for (int i = Min; i > k; i--) {
    bool ck = 0;
    int j;
    for (j = i; j < N; j += i) {
      if (cnt[j - 1] - cnt[j - i + k]) {
        ck = 1;
        break;
      }
    }
    if (j - i + k < N && cnt[N - 1] - cnt[j - i + k]) ck = 1;
    if (!ck) return cout << i, 0;
  }
  cout << min(Min, k) << "\n";
}
