#include <bits/stdc++.h>
using namespace std;
int solve(int n, int k, vector<int> &arr, int mn) {
  int MX = int(1e6);
  if (k >= mn - 1) return mn;
  int i, j;
  for (i = mn; i >= k + 1; i--) {
    int tot = 0;
    for (j = 0; j <= MX; j += i) {
      int mx = min(j + k, MX);
      tot += (arr[mx] - (j > 0 ? arr[j - 1] : 0));
    }
    if (tot == n) return i;
  }
  return -33;
}
int main() {
  int MX = (1e6) + 2;
  vector<int> arr(MX - 1, 0);
  int n;
  scanf("%d", &n);
  int k;
  scanf("%d", &k);
  int i, j;
  int mn = MX;
  for (i = 0; i < n; i++) {
    int temp;
    scanf("%d", &temp);
    mn = min(mn, temp);
    arr[temp]++;
  }
  for (i = 1; i < MX; i++) arr[i] += arr[i - 1];
  printf("%d\n", solve(n, k, arr, mn));
}
