#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int N, K;
int A[300300];
int dp[1000010];
int main() {
  scanf("%d%d", &N, &K);
  int min_num = 1000000000;
  int max_num = 0;
  for (int i = 0; i < N; ++i) {
    scanf("%d", A + i);
    if (A[i] < min_num) min_num = A[i];
    if (A[i] > max_num) max_num = A[i];
    ++dp[max(A[i] - K, 1)];
    --dp[A[i] + 1];
  }
  int ans = 0;
  if (min_num <= K)
    ans = min_num;
  else {
    ans = K;
    for (int i = 1; i < 1000010; ++i) dp[i] += dp[i - 1];
    ++max_num;
    for (int g = K + 1; g <= min_num; ++g) {
      int say = 0;
      for (int div = g; div < max_num; div += g) say += dp[div];
      if (say == N) ans = g;
    }
  }
  cout << ans << endl;
  return 0;
}
