#include <bits/stdc++.h>   using namespace std;   int n, k, a[2000005];   int val[2000005], sumVal[2000005];   int getSum(int l, int r) {     if (l == 0)       return sumVal[r];     else       return sumVal[r] - sumVal[l - 1];   }   int main() {     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> a[i];       val[a[i]]++;     }     for (int i = 1; i < 2000005; i++) {       sumVal[i] = sumVal[i - 1] + val[i];     }     sort(a, a + n);     if (a[0] <= k + 1) {       cout << a[0];       return 0;     }     long long ans = k;     for (int d = k + 1; d <= a[0]; d++) {       int res = 0;       for (int i = 0; d * i <= a[n - 1]; i++) {         res += getSum(d * i, d * i + k);       }       if (res == n) ans = d;     }     cout << ans;   }   