#include <iostream>
#include <cmath>
using namespace std;

const int N = 100000001;

int main()
{
    int n, x;
    cin >> n >> x;
    int max1 = -N, min1 = N;
    for (int i = 0; i < n; i++) {
        int y;
        cin >> y;
        max1 = max(max1, y);
        min1 = min(min1, y);
    }
    cout << max1 - min1 + (abs(x - min1) > abs(max1 - x)?abs(max1 - x):abs(x - min1));
    return 0;
}