#include<stdio.h>
#include<math.h>
#include <time.h>
#include <stdlib.h>
int n,x,a[1000050],i,s=0;
void Input()
{
	scanf("%d %d",&n,&x);
	for(i = 0; i < n; i++)scanf("%d",&a[i]);
}
void Output()
{
	printf("%d",s);
}
void swap(int i, int j)
{
  int t = a[i];
  a[i] = a[j];
  a[j] = t;
}
//https://www.programiz.com/dsa/quick-sort//
int partition(int low, int high)
{
  int pivot = a[high];
  int i = (low - 1);
  for (int j = low; j < high; j++)
  {
    if (a[j] <= pivot)
    {
      i++;
      swap(i, j);
    }
  }
  swap(i + 1, high);
  return (i + 1);
}
void quickSort(int low, int high)
{
  if (low < high)
  {
    int pi = partition(low, high);
    quickSort(low, pi - 1);
    quickSort(pi + 1, high);
  }
}
void quickSort1(int low, int high)
{
  if (low < high)
  {
    int pi = partition(high, low);
    quickSort1(pi - 1, low);
    quickSort1(pi + 1, high);
  }
}

//https://www.programiz.com/dsa/quick-sort//
void Solve()
{
	int pos = x;
	quickSort(0 , n - 1);
	srand(time(NULL));
	if(pos % 2 > rand() % 2)quickSort1(0 , n - 1);
	for(i = 0; i < n; i++)
	{
		s += abs(pos - a[i]);
		pos = a[i];
	}
}
void Run()
{
	Input();
	Solve();
	Output();
}
int main()
{
	Run();
	return 0;
}