#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	long long x, l[1000], n, d;
	cin >> n >> x;
	for (int i = 0; i < n; i++)
	{
		cin >> l[i];
		l[i] = l[i] - x;
	}
	l[n] = 0;
	sort(begin(l), end(l), greater<>());
	if (l[0] == 0)
	{
		d = l[n];
	}
	else if (l[n] == 0)
	{
		d = l[0];
	}
	else if (abs(l[0]) < abs(l[n]))
	{
		d = 2 * abs(l[0]) + abs(l[n]);
	}
	else
	{
		d = 2 * abs(l[n]) + abs(l[0]);
	}
	cout << d << endl;
	return 0;
}