#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    long long n, x, mx, mn, a;
    cin >> n >> x;
    mx = x; mn = x;
    while(n--)
    {
        cin >> a;
        if(a > mx) mx = a;
        if(a < mn) mn = a;
    }
    mn = abs(x - mn);
    mx = abs(x - mx);
    if(mx < mn) swap(mn, mx);
    cout << 2*mn + mx;
    return 0;
}