#include<iostream>
#include<cstdlib> 

using namespace std;

int main()
{
    long long int n, x, min1 = 99999999, max1 = -99999999;
    long long int brsek;
    cin >> n >> x;

    long long int a[n];
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(a[i] < min1)
        {
            min1 = a[i];
        }
        if(a[i] > max1)
        {
            max1 = a[i];
        }
    }
    if(x > max1)
    {
        brsek = abs(x - min1);
    }
    else if(x < min1)
    {
        brsek = abs(max1 - x);
    }
    else
    {
        if(abs(min1) > abs(max1))
        {
            brsek = abs(2*(max1 - x) + x - min1);
        }
        else
        {
            brsek = abs(2*(x - min1) + max1 - x);
        }
    }

    cout << brsek;
}