#include <iostream>


using namespace std;


int main()
{
    int n, x, d, i = 0;
    cin >> n >> x;
    int minNeg = 1, maxPos = -1;
    while(i!=n)
    {
        cin >> d;
        if(d-x<0)
            minNeg =  min(minNeg,d-x);
        else
            maxPos = max(maxPos,d-x);
        i++;
    }

    if(minNeg == 1)
    {
        cout << maxPos;
    }
    else if(maxPos == -1 || maxPos == 0)
    {
        cout <<  -minNeg;
    }
    else
    {
        int res =(-minNeg>maxPos) ? 2*maxPos-minNeg : 2*-minNeg+maxPos;
        cout << res;

    }
    return 0;
}