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

int main()
{
	int a, b, min, max;
	long long k = 0, d, f;
	ios_base::sync_with_stdio(false);
	cin >> a >> b;
	vector<int>x(a);
	for (int i = 0; i < a; ++i)
		cin >> x[i];
	sort(x.begin(), x.end());
	min = x.front(); max = x.back();
	if (b >= 0) { d = max - b;  f = b - min; }
	else { d = max - b;  f = abs(min) - abs(b); }
	if (d < f) k = d + f + d;
	else if (f <= 0) k = d;
	else k = f + d + f;
	cout << k;
}