#include <iostream>


int main()
{


	int n, x, rez = 0;
	int min1, max1;
	int min = INT_MAX;
	int max = INT_MIN;
	int sused;
	scanf("%d %d", &n, &x);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &sused);
		if (sused < min)
			min = sused;
		if (sused > max)
			max = sused;
	}
	if (x > min) {
		max1 = x;
		min1 = min;
	}
	else {
		max1 = min;
		min1 = x;
	}

	rez = max1 - min1 + max - min;

	printf("%d", rez);

}