#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[300010];
int cnt[1000010];
int lessn;
int maxn;
bool good(int d) {
  int ans = 0;
  for (int i = 0; i <= maxn; i += d) {
    int p = min(i + k, maxn);
    int q = max(1, i);
    ans += cnt[p] - cnt[q - 1];
  }
  return (ans == n);
}
int main() {
  scanf("%d %d", &n, &k);
  lessn = INT_MAX;
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    cnt[a[i]] += 1;
    lessn = min(lessn, a[i]);
    maxn = max(maxn, a[i]);
  }
  for (int i = 1; i <= maxn; i++) {
    cnt[i] += cnt[i - 1];
  }
  int ans = min(k, lessn);
  for (int i = lessn; i > k; i--) {
    if (good(i)) {
      ans = i;
      break;
    }
  }
  printf("%d\n", ans);
  return 0;
}
