#include <iostream> 
#include <vector>

using namespace std;

int main()
{
	int n, maxR, maxL, x;
	int l;
	int temp;
	vector<int> a;
	maxR = 0;
	maxL = 0;
	l = 0;

	cin >> n >> x;
	
	for (int i = 0; i < n; i++) {
		cin >> temp;
		a.push_back(temp);
	}
	
	for (int i = 0; i < n; i++) {
		if (x > a[i]) {
			if (maxR < abs(a[i] - x)) {
				maxR = abs(a[i] - x);
			}
		} 
		else if (maxL < abs(a[i] - x)) {
			maxL = abs(a[i] - x);
		}
	}
	if (maxR < maxL) {
		l = 2 * maxR + maxL;
	}
	else {
		l = 2 * maxL + maxR;
	}
	cout << l;

	return 0;
}