#include <bits/stdc++.h>
using namespace std;
int p[1001000];
int a[300100];
int n;
int k;
const int MAX = 1e6;
int possible(int gcd) {
  int i = 0;
  while (true) {
    int st = gcd * i, nxt = gcd * (i + 1) - 1, e = min(nxt, MAX);
    int fin = min(st + k, MAX);
    int total = p[e] - (st == 0 ? 0 : p[st - 1]);
    if (i == 0 && total > 0) return 0;
    int possible = p[fin] - (st == 0 ? 0 : p[st - 1]);
    if (total > possible) return 0;
    if (nxt + 1 > 1e6) return 1;
    i++;
  }
}
int main(void) {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    p[a[i]]++;
  }
  for (int i = 1; i <= MAX; i++) p[i] += p[i - 1];
  for (int i = MAX; i >= 1; i--) {
    if (possible(i)) {
      printf("%d\n", i);
      return 0;
    }
  }
}
