#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 7;
const int N = (int)3e5 + 20;
const int M = (int)2e6 + 2;
const int K = 25;
int b[K][M], x[M], h[K];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int f = inf;
  for (int i = 0; i < n; ++i) {
    int a;
    scanf("%d", &a);
    b[0][a] = a;
    f = min(f, a);
  }
  for (int i = 0; i < K; ++i) {
    h[i] = int(1 << i);
  }
  for (int i = 1; i < M; ++i) {
    for (int j = 0; h[j] <= i; ++j) {
      x[i] = j;
    }
  }
  for (int i = 1; h[i] <= M; ++i) {
    for (int j = 0; j + h[i] <= M; ++j) {
      b[i][j] = max(b[i - 1][j], b[i - 1][j + h[i - 1]]);
    }
  }
  int ans = 1;
  for (int i = 2; i <= f; ++i) {
    int v = x[i - 1];
    int d = h[v];
    bool q = 1;
    for (int j = i; j + i < M; j += i) {
      int p = max(b[v][j + 1], b[v][j + i - d]);
      if (p - k > j) {
        q = 0;
        break;
      }
    }
    if (q) {
      ans = i;
    }
  }
  printf("%d", ans);
  return 0;
}
