#include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 1000;
int a[N], f[N + 10];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, k, minn = N + 1;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    minn = min(a[i], minn);
    f[a[i] + 1]--;
    f[max(1, a[i] - k)]++;
  }
  for (int i = 2; i <= N; i++) f[i] += f[i - 1];
  for (int i = N; i > k + 1; i--) {
    int num = 0;
    for (int j = i; j <= N; j += i) num += f[j];
    if (num >= n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << min(minn, k + 1) << endl;
  return 0;
}
