#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);

    int64_t n, x;
    cin >> n >> x;

    vector<int64_t> v(n, 0);
    for(auto i = 0; i < n; i++)
        cin >> v[i];

    int64_t mn = *min_element(begin(v), end(v));
    int64_t mx = *max_element(begin(v), end(v));

    cout << (abs(x - mn) + (mx - mn)) << '\n';

    cout.flush();
    return 0;
}