#include <bits/stdc++.h>
int n, m;
int f[2000010], mx, mn = (int)1e7;
short check(int x) {
  int i;
  for (i = x; i <= mx; i += x)
    if (f[i + x - 1] >= i && f[i + x - 1] - i > m) return 0;
  return 1;
}
int main() {
  int i, x;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    f[x] = x;
    mx = mx > x ? mx : x;
    mn = mn < x ? mn : x;
  }
  mx <<= 1;
  for (i = 1; i <= mx; i++) f[i] = f[i] > f[i - 1] ? f[i] : f[i - 1];
  mx >>= 1;
  for (i = mn; i > 1; i--)
    if (check(i)) break;
  printf("%d", i);
  return 0;
}
