#include <bits/stdc++.h>
using namespace std;
int const nMax = 3e5 + 100;
int const Max = 1e6 + 1000;
int a[nMax], num;
int d[2 * Max], p[nMax];
bool mark[Max];
int main() {
  int n, k, y, m, ans = 1, temp;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a + 1, a + 1 + n);
  memset(d, 0, sizeof(d));
  y = 1;
  m = 1;
  while (y <= a[n] && m <= n) {
    d[y] = d[y - 1];
    while (a[m] <= y && m <= n) {
      d[y]++;
      m++;
    }
    y++;
  }
  y = 2 * Max;
  for (int i = a[n] + 1; i <= y; i++) d[i] = d[i - 1];
  memset(mark, true, sizeof(mark));
  for (int i = 2; i <= a[1]; i++) {
    if (!mark[i]) continue;
    if (k >= i) {
      ans = max(ans, i);
      continue;
    }
    temp = 0;
    for (int j = 1;; j++) {
      if (i * j - 1 > a[n]) break;
      temp += (d[i * j + k] - d[i * j - 1]);
    }
    if (temp == n)
      ans = max(ans, i);
    else {
      int countnum = a[n] / i + 1;
      for (int j = 1; j <= countnum; j++) mark[i * j] = false;
    }
  }
  cout << ans << endl;
}
