#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    long int n,x;
    long int num,maxx,minn;
    long int distance_right , distance_left,score;
    cin >> n >> x;
    maxx = x;
    minn = x;

    for(int i = 0 ; i < n;i++)
    {
        cin >> num;
        if(num > maxx)
        {
            maxx = num;
        }
        if(num < minn)
        {
            minn = num;
        }

    }
    if(minn < 0)
    {
        x+=abs(minn);
        maxx+=abs(minn);
        minn = 0;
    } else
    {
        x+=-minn;
        maxx+=-minn;
        minn = 0;
    }

    if(x!=0)
    {
        distance_left = x;
    } else
    {
        distance_left = 0;
    }
    distance_right=maxx-x;

    if(minn == x)
    {
        score = maxx;
    } else if(maxx == x)
    {
        score = maxx;
    } else if(distance_left <= distance_right)
    {
        score = distance_left*2+distance_right;
    } else
    {
        score = distance_right*2+distance_left;
    }

    cout << score;
}