#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
int a[MAXN];
int main() {
  int n, k, z = MAXN;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    z = min(z, x);
    a[x]++;
    a[max(0, x - k - 1)]--;
  }
  for (int i = MAXN - 2; i >= 0; i--) {
    a[i] += a[i + 1];
  }
  for (int i = MAXN - 1; i >= 1; i--) {
    int x = 0;
    for (int j = i; j < MAXN; j += i) {
      x += a[j];
    }
    if (x >= n) {
      printf("%d", min(i, z));
      return 0;
    }
  }
}
