import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.exception;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import core.bitop;

immutable int MED_N = 1_000_006;
immutable int MAX_N = MED_N * 2 + 1;

void main ()
{
	int n, k;
	while (scanf (" %d %d", &n, &k) > 0)
	{
		auto a = new int [MAX_N * 2];
		int m = MED_N - 1;
		foreach (i; 0..n)
		{
			int v;
			scanf (" %d", &v);
			a[v]++;
			m = min (m, v);
		}
		auto s = new int [MAX_N];
		s[0] = 0;
		foreach (i; 1..MAX_N)
		{
			s[i] = s[i - 1] + a[i];
		}
		int res = 1;
		foreach_reverse (d; 2..m + 1)
		{
			bool ok = true;
			for (int i = d * 2; i < MAX_N; i += d)
			{
				int j = min (i - d + k, i);
				if (s[i - 1] > s[j])
				{
					ok = false;
					break;
				}
			}
			if (ok)
			{
				res = d;
				break;
			}
		}
		writeln (res);
	}
}
