#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target( \
    "fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << '{';
  string sep;
  for (const auto &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
template <typename T, size_t size>
ostream &operator<<(ostream &os, const array<T, size> &arr) {
  os << '{';
  string sep;
  for (const auto &x : arr) os << sep << x, sep = ", ";
  return os << '}';
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << ' ' << H;
  debug_out(T...);
}
const int MAX_N = 2e6 + 5;
int dp[MAX_N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k, mn = 1e9;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int foo;
    cin >> foo;
    mn = min(mn, foo);
    dp[foo] = 1;
  }
  int where = -1;
  for (int i = 0; i < MAX_N; i++) {
    if (dp[i]) {
      where = i;
    }
    dp[i] = where;
  }
  int best_way = 1;
  for (int i = 1; i <= mn; i++) {
    for (int j = 1;; j++) {
      const int lo = i * (j - 1);
      const int hi = i * j;
      if (hi >= MAX_N) break;
      int s = dp[hi - 1];
      if (s == -1 || s <= lo) continue;
      int lim = s - k;
      if (lim > lo) {
        47;
        goto invalid;
      }
    }
    best_way = i;
  invalid:;
  }
  cout << best_way << '\n';
  return 0;
}
