#include <bits/stdc++.h>
using namespace std;
int val[1000000 + 10];
int a[300010];
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    val[max(1, a[i] - k)]++;
    val[a[i] + 1]--;
  }
  sort(a, a + n);
  for (int i = 1; i <= 1000000; i++) val[i] += val[i - 1];
  int ans = min(k + 1, a[0]);
  for (int i = k + 2; i <= a[0]; i++) {
    int tmp = 0;
    for (int j = i; j <= 1000000; j += i) tmp += val[j];
    if (tmp == n) ans = i;
  }
  cout << ans << endl;
}
