#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7107;
int n, k, mi, mx, tot, ans, a[300005], cnt[3000005];
int main() {
  scanf("%d%d", &n, &k);
  mi = INF;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    mi = min(mi, a[i]), mx = max(mx, a[i]);
    cnt[a[i]]++;
  }
  if (mi <= k + 1) {
    printf("%d\n", mi);
    return 0;
  }
  ans = k + 1;
  for (int i = 1; i <= 3000000; i++) cnt[i] += cnt[i - 1];
  for (int i = k + 2; i <= mi; i++) {
    tot = 0;
    for (int j = i; j - i + k <= mx; j += i) {
      tot += cnt[j + k] - cnt[j - 1];
    }
    if (tot == n) ans = max(ans, i);
  }
  printf("%d\n", ans);
  return 0;
}
