#include <bits/stdc++.h>
int w[2000010], s[2000010];
int main() {
  int N, K, ans, i;
  while (scanf("%d%d", &N, &K) != EOF) {
    memset(w, 0, sizeof(w));
    for (i = 1; i <= N; i++) {
      int x;
      scanf("%d", &x);
      w[x]++;
    }
    s[0] = 0;
    for (i = 1; i < 2000010; i++) s[i] = s[i - 1] + w[i];
    for (i = 1000000; i >= 1; i--) {
      if (s[i - 1] > 0) continue;
      bool getdiv = true;
      for (int j = i; j <= 1000000; j += i)
        if ((s[j + i - 1] - s[j]) > (s[j + K] - s[j])) {
          getdiv = false;
          break;
        }
      if (getdiv) {
        ans = i;
        break;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
