#include <bits/stdc++.h>
using namespace std;
int sum[1000000 + 5];
int n, k, maxnum, minnum;
bool check(int p) {
  for (int i = 0; i < maxnum; i += p) {
    int l = i + k;
    int r = min(maxnum, i + p - 1);
    if (l < r && sum[r] - sum[l] > 0) return false;
  }
  return true;
}
int main() {
  scanf("%d%d", &n, &k);
  memset(sum, 0, sizeof(sum));
  maxnum = 1;
  minnum = 1000000;
  for (int i = 1; i <= n; i++) {
    int p;
    scanf("%d", &p);
    sum[p] = 1;
    maxnum = max(maxnum, p);
    minnum = min(minnum, p);
  }
  for (int i = 2; i <= maxnum; i++) sum[i] += sum[i - 1];
  for (int i = minnum; i >= 1; i--)
    if (check(i)) {
      printf("%d\n", i);
      break;
    }
  return 0;
}
