#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-8;
const double PI = acos(-1);
int imos[1000010];
int num[1000010];
int main() {
  int n, k;
  while (cin >> n >> k) {
    memset(imos, 0, sizeof(imos));
    int ans = k;
    for (int i = 0; i < (int)n; ++i) {
      int a;
      scanf("%d", &a);
      ans = min(ans, a);
      imos[max(0, a - k)]++;
      imos[a + 1]--;
    }
    for (int i = 0; i < (int)1000010; ++i) {
      num[i] = (i ? num[i - 1] : 0) + imos[i];
    }
    for (int i = k + 1; i <= 1000000; ++i) {
      int sum = 0;
      for (int j = i; j <= 1000000; j += i) {
        sum += num[j];
      }
      if (sum == n) ans = i;
    }
    cout << ans << endl;
  }
}
