#include <iostream>

using namespace std;

int main()
{
    int n, x;
    int maxLevi = 0;
    int maxDesni = 0;
    cin >> n; cin >> x;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (a < x)
        {
            maxLevi = x - a;
        }
        if (a > x)
        {
            maxDesni = a - x;
        }
    }
    int max = 0;
    if (maxLevi < maxDesni)
        max = 2 * maxLevi + maxDesni;
    else
        max = 2 * maxDesni + maxLevi;
    cout << max;
    return 0;
}