#include <iostream>
#define max(a, b)  (((a) > (b)) ? (a) : (b))
#define min(a, b)  (((a) < (b)) ? (a) : (b))
#define abs(x) (((x)<0)?-(x):(x))
#define endl '\n'
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << x << endl;
#define MAX_N 1000000
using namespace std;

inline int add(int x, int y)
{
	if ((x < 0 && y < 0) || (x > 0 && y > 0)) return abs(x - y);
	return abs(x) + abs(y);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, x;
	bool foundL = 0, foundR = 0;
	cin >> n >> x;
	int minL = 2147483647, maxR = -2147483647; 
	for (int i = 0; i < n; i++)
	{
		int a; cin >> a;
		if (a < x) { foundL = 1; minL = min(minL, a); }
		else { foundR = 1;  maxR = max(maxR, a); }
	}
	if (!foundL) { cout << add(x, maxR) << endl; return 0; }
	else if (!foundR) { cout << add(x, minL) << endl; return 0; }
	int diffL = add(minL, x),
		diffR = add(maxR, x);
	if (diffL < diffR)
		cout << 2 * diffL + diffR << endl;
	else cout << 2 * diffR + diffL << endl;
}