#include <bits/stdc++.h>
using namespace std;
int a, b, arr[1000009], srr[1000009], n, h = 1000000007;
int main() {
  scanf("%d%d", &a, &b);
  for (int i = 1; i <= a; i++) {
    scanf("%d", &arr[i]);
    if (arr[i] > n) n = arr[i];
    if (h > arr[i]) h = arr[i];
    if (b >= arr[i])
      srr[1]++, srr[arr[i] + 1]--;
    else
      srr[arr[i] - b]++, srr[arr[i] + 1]--;
  }
  for (int i = 1; i <= 1000009; i++) srr[i] += srr[i - 1];
  while (h > 0) {
    int k = 0;
    int u = 0;
    k = h;
    while (k <= n) {
      u += srr[k];
      k += h;
    }
    if (u >= a) {
      cout << h << " ";
      return 0;
    }
    h--;
  }
  return 0;
}
