#include <bits/stdc++.h>
using namespace std;
void qs(int *a, int l, int r) {
  int i = l;
  int j = r;
  int y, p = a[(l + r) >> 1];
  do {
    while (a[i] < p && i < r) i++;
    while (a[j] > p && j > l) j--;
    if (i <= j) {
      y = a[i];
      a[i] = a[j];
      a[j] = y;
      i++;
      j--;
    }
  } while (i <= j);
  if (i < r) qs(a, i, r);
  if (j > l) qs(a, l, j);
}
int main() {
  int n, k, t, mx, mn = (int)1E9;
  bool f;
  scanf("%d %d", &n, &k);
  int *a = new int[1000010];
  for (int i = 0; i < (int)1000010; i++) a[i] = 0;
  for (int i = 0; i < (int)n; i++) {
    scanf("%d", &t);
    if (t < mn) mn = t;
    if (!a[t]) a[t] = 1;
  }
  for (int i = (int)1; i < (int)1000001; i++) a[i] = a[i - 1] + a[i];
  if (k >= mn - 1) {
    printf("%d\n", mn);
    return 0;
  }
  mx = max(2, k + 1);
  for (int i = (int)k + 2; i < (int)mn + 1; i++) {
    f = 1;
    for (int j = (int)1; j < (int)1000000; j++) {
      if (j * i >= 1000000) break;
      if (a[min((j + 1) * i - 1, 1000000)] -
          a[min(j * i + k, min((j + 1) * i - 1, 1000000))]) {
        f = 0;
        break;
      }
    }
    if (f) mx = i;
  }
  printf("%d\n", mx);
  return 0;
}
