#include <bits/stdc++.h>
using namespace std;
const int M = 1e6;
int dp[2 * M + 11];
int main() {
  int N, K;
  scanf("%d%d", &N, &K);
  for (int i = 0; i <= 2 * M; ++i) {
    dp[i] = 1e9;
  }
  for (int i = 0; i < N; ++i) {
    int x;
    scanf("%d", &x);
    int b = max(1, x - K);
    dp[b - 1] = min(dp[b - 1], x);
  }
  for (int i = M; i >= 0; --i) {
    dp[i] = min(dp[i], dp[i + 1]);
  }
  for (int c = M; c >= 1; --c) {
    bool ok = true;
    for (int i = 0; dp[i] < 1e8; i += c) {
      if (dp[i] < i + c) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << c << '\n';
      break;
    }
  }
  return 0;
}
