#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while ((~c && c < '0') || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
int X[] = {-1, 0, 1, 0};
int Y[] = {0, 1, 0, -1};
int n, k, arr[300010];
bool isInside(int r, int div) { return (r % div <= k); }
int main() {
  read(n);
  read(k);
  for (int i = 0; i < n; i++) {
    read(arr[i]);
  }
  sort(arr, arr + n);
  int ans = arr[0];
  while (true) {
    bool flag = false;
    for (int i = 0; i < n; i++) {
      while (!isInside(arr[i], ans)) ans--, flag = true;
    }
    if (!flag) break;
  }
  printf("%d\n", ans);
  return 0;
}
