#include <bits/stdc++.h>
using namespace std;
int N, K, minA = 0x3f3f3f3f, maxA;
int A[300002], result;
int F[1000002];
int main() {
  cin.sync_with_stdio(false);
  cin >> N >> K;
  for (int i = 1; i <= N; ++i) {
    cin >> A[i];
    minA = min(minA, A[i]);
    maxA = max(maxA, A[i]);
    ++F[A[i]];
  }
  for (int i = 1; i <= 1000000; ++i) F[i] += F[i - 1];
  sort(A + 1, A + N + 1);
  if (K + 1 >= A[1])
    result = A[1];
  else
    result = K + 1;
  for (int i = A[1]; i >= result + 1; --i) {
    bool nok = false;
    if (i <= 1000) {
      for (int j = 1; j <= N; ++j)
        if (A[j] % i > K) {
          nok = true;
          break;
        }
    } else {
      int lastdone = 0, resnow = 0;
      for (int j = i; j <= maxA; j += i) {
        resnow += F[min(maxA, j + K)] - F[max(j - 1, lastdone)];
        lastdone = j + K;
      }
      if (resnow != N) nok = true;
    }
    if (!nok) {
      result = i;
      break;
    }
  }
  cout << result << '\n';
}
