#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int a[1000001];
void heapify(int arr[], int n, int i)
{
    int largest = i;
    int l = 2 * i + 1;
    int r = 2 * i + 2;

    if (l < n && arr[l] > arr[largest])
        largest = l;


    if (r < n && arr[r] > arr[largest])
        largest = r;


    if (largest != i) {
        swap(arr[i], arr[largest]);


        heapify(arr, n, largest);
    }
}


void heapSort(int arr[], int n)
{

    for (int i = n / 2 - 1; i >= 0; i--)
        heapify(arr, n, i);


    for (int i = n - 1; i >= 0; i--) {

        swap(arr[0], arr[i]);


        heapify(arr, i, 0);
    }
}
int main()
{
int n,x,i,s=0,br=0;
scanf("%d%d",&n,&x);
for(i=0;i<n;i++)
    scanf("%d",&a[i]);
n++;
a[n-1]=x;
heapSort(a,n);

for(i=0;i<n-1;i++){

    if(a[i+1]==x){
    br++;
    s+=abs(a[i+1]-a[i]);
    }
    else if(a[i]==x&&br==1)
    {
        br++;
        s+=abs(a[i+1]-a[i-1]);
    }
    else{
        s+=abs(a[i+1]-a[i]);
    }


}
printf("%d",s);
}