#include <iostream>
using namespace std;

int n;
int x;
int a;

int min;
int max;
int current;

int main() {
    
    cin >> n >> x;

    
    for (int k = 0; k < n; k++) {
        cin >> a;
        if (k == 0) {
            min = a;
            max = a;
        }
        else {
            if (a > max) {
                max = a;
            }
            if (a < min) {
                min = a;
            }
        }
    }


    x = x + abs(min);
    max = max + abs(min);
    min = min + abs(min);

    if (x == min or x == max) {
        cout << max - min;
    }
    else {
        if (max - x > x - min) {
            cout << 2 * (x - min) + (max - x);
        }
        else {
            cout << 2 * (max - x) + (x - min);
        }
    }
}