#include <iostream>
#include <algorithm>
#define ll long long

using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	ll pocetni_x; cin >> pocetni_x;
	ll min_x = pocetni_x, max_x = pocetni_x, tr_x;
	for (size_t i = 0; i < n; i++)
	{
		cin >> tr_x;
		min_x = min(min_x, tr_x);
		max_x = max(max_x, tr_x);
	}
	ll duzina_puta = abs(max_x - min_x);
	if (abs(min_x) < abs(max_x))
	{
		if (min_x != pocetni_x)
			cout << abs(pocetni_x - min_x) + duzina_puta;
		else
			cout << abs(pocetni_x - max_x);
	}
	else
	{
		if (max_x != pocetni_x)
			cout << abs(pocetni_x - max_x) + duzina_puta;
		else
			cout << abs(pocetni_x - min_x);
	}
	return 0;
}