#include <iostream>
using namespace std;
int main()
{
    long int n,x,i,ml=0,md=0,p;
    cin >> n >> x;
    for (i=0;i<n;i++)
    {
        cin >> p;
        if (x-p>ml)
            ml=x-p;
        if (p-x>md)
            md=p-x;
    }
    if (ml>md)
        md*=2;
    else
        ml*=2;
    ml+=md;
    cout << ml;
    return 0;
}