#include <bits/stdc++.h>
using namespace std;
int n;
long long a[1000010],x,resenje=0;
long long min_0=9999999999,max_0=-9999999999,dox,odx;
int main (){
    scanf("%d %lld",&n,&x);
    for(int i = 1; i <= n; i++){
        scanf("%lld",&a[i]);
        min_0=min(min_0,a[i]);
        max_0=max(max_0,a[i]);
    }
    if(min_0<0 and x>0){
        odx=abs(abs(min_0)+x);
    }
    if(min_0>0 and x<0){
        odx=abs(abs(x)+min_0);
    }
    if(min_0<0 and x<0){
        odx=abs(min_0-x);
    }
    if(min_0>0 and x>0){
        odx=abs(min_0-x);
    }
    if(max_0>0 and x<0){
        dox=abs(max_0+abs(x));
    }
    if(max_0<0 and x>0){
        dox=abs(abs(max_0)+x);
    }
    if(max_0>0 and x>0){
        dox=abs(max_0-x);
    }
    if(max_0<0 and x<0){
        dox=abs(max_0-x);
    }
    if(x==0){dox=abs(max_0);odx=abs(min_0);}
    if(max_0==0){dox=abs(x);}
    if(min_0==0){odx=abs(x);}
//    cout << dox << " " << odx << endl;
    if(min_0==max_0){cout<<odx<<endl;return 0;}
    if(odx==dox){cout<<dox*3<<endl;return 0;}
    if(min_0>x and max_0>x){
        cout << dox << endl;
        return 0;
    }
    if(min_0<x and max_0<x){
        cout << odx << endl;
        return 0;
    }
    cout<<dox+odx+min(odx,dox)<<endl;
return 0;
}