#include<cstdio>

using namespace std;
int main(){
    int n, x, t = 0;
    long int r;
    scanf("%d %d", &n, &x);
    int mn = x; int mx = x;
    for(int i = 0;i<n;i++){
        scanf("%d", &t);
        if(t>mx) mx=t;
        else if(t<mn) mn=t;
        //cout<<mx<<" "<<mn<<" "<<t<<endl;
    }
    if(x-mn>mx-x){
        r=2*mx-x-mn;
        //cout<<endl<<"prvi";
    }
    else{
        r = mx+x-2*mn;
    }
    printf("%li", r);
}