#include <iostream>
using namespace std;

int main()
{
   ios_base::sync_with_stdio(false);
   long n,x,n2,min=100000000,max=-100000000;
   cin>>n>>x;
    for(long i=0;i<n;i++)
    {
        cin>>n2;
        max=n2>max ? n2:max;
        min=n2<min ? n2:min;
    }
    min+=100000000;
    max+=100000000;
    x+=100000000;
    if(min>x)
        cout<<max-x;
    else if(max<x)
        cout<<x-min;
    else
        cout<<(x-min)*2+max-x;
}