import std.stdio;
import std.algorithm;
import std.conv;
import std.math;
import std.string;

void main()
{
	auto tokens1 = split(chomp(readln()));
	auto tokens2 = split(chomp(readln()));
	auto n = to!int(tokens1[0]);
	auto x = to!int(tokens1[1]);
	int[] xs;
	xs ~= 0;
	foreach (token; tokens2)
	{
		xs ~= to!int(token) - x;
	}
	xs.sort;

	int d = abs(xs[0]);
	foreach (i; 1..xs.length)
	{
		auto tmp = abs(xs[i] - xs[i-1]);
		if (tmp < d) d = tmp;
	}

	writeln(d);
	stdout.flush();
}