#include <bits/stdc++.h>
long long mpow(long long a, long long n, long long mod) {
  long long ret = 1;
  long long b = a;
  while (n) {
    if (n & 1) ret = (ret * b);
    b = (b * b);
    n >>= 1;
  }
  return (long long)ret;
}
using namespace std;
int a[3 * 100003];
int cnt[1000003];
int main() {
  int i, j, n, k;
  cin >> n >> k;
  int max1 = -1;
  for (j = 0; j < n; j++) {
    cin >> a[j];
    cnt[a[j]]++;
  }
  for (j = 1; j <= 1000003 - 3; j++) cnt[j] += cnt[j - 1];
  int ans = 1;
  for (i = 1; i <= 1000003 - 3; i++) {
    if (cnt[i - 1] > 0) continue;
    if (i <= k) {
      ans = i;
      continue;
    }
    int tot = 0;
    for (int p = i; p <= 1000003 - 3; p += i) {
      tot += (cnt[min(p + k, 1000003 - 3)] - cnt[p - 1]);
    }
    if (tot >= n) {
      ans = max(ans, i);
    }
  }
  cout << ans;
  return 0;
}
