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;
	foreach (token; tokens2)
	{
		xs ~= to!int(token);
	}

	int d = int.max;
	foreach (i; 0..xs.length)
	{
		int lhs = xs[i] - x;
		int lhs_abs = abs(lhs);
		if (lhs_abs < d) d = lhs_abs;
		foreach (j; i+1..xs.length)
		{
			int rhs = xs[j] - x;
			int tmp = abs(lhs - rhs);
			if (tmp < d) d = tmp;
		}
	}

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