#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
const int M = 1e5 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
int n, k, cnt[N];
struct node {
  int l, r;
} a[N];
int main() {
  scanf("%d%d", &n, &k);
  int mn = inf;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].r);
    mn = min(mn, a[i].r);
    a[i].l = max(1, a[i].r - k);
    cnt[a[i].l]++;
    cnt[a[i].r + 1]--;
  }
  for (int i = 1; i <= 1000000; i++) cnt[i] += cnt[i - 1];
  int ans = min(mn, k);
  if (mn > k) {
    for (int i = k + 1; i <= 1000000; i++) {
      int num = 0;
      for (int j = i; j <= 1000000; j += i) num += cnt[j];
      if (num == n) ans = i;
    }
  }
  printf("%d\n", ans);
  return 0;
}
