#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 1000010, LOG = 20;
int n, m, k, u, v, x, y, t, a, b, ans;
int A[MAXN];
long long cnt[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    cnt[A[i] + 1]--;
    cnt[max(1, A[i] - k)]++;
  }
  sort(A + 1, A + n + 1);
  for (int i = 1; i < MAXN; i++) cnt[i] += cnt[i - 1];
  for (int i = 1; i < MAXN; i++)
    for (int j = 2 * i; j < MAXN; j += i) cnt[i] += cnt[j];
  for (int i = A[1]; i; i--)
    if (cnt[i] >= n) return cout << i << '\n', 0;
  return 0;
}
