#include <iostream>

using namespace std;

int main()
{
    int x,n,l=0,d=0,a,i;
    cin >> n >> x;
    for(i=0;i<n;i++){
        cin >> a;
        if(a>x)
            if(a-x > d)
                d = a-x;
        if(a<x)
            if(x-a > l)
                l = x-a;
    }
    //cout << l << " " << d;
    if(l==0)
        cout << d;
    else if (d==0)
        cout << l;
    else if (d<l)
        cout << l+d+d;
    else
        cout << l+d+l;

    return 0;
}