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

int n;
int x;
int a;

int min;
int max;
int current;

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

    vector<int> map(n+1);
    
    for (int k = 0; k < n; k++) {
        cin >> a;
        map[k] = a;
    }

    map[n] = x;
    
    int min = map[0];
    int max = map[0];
    int current = 0;

    for (int k = 0; k < n+1; k++) {
        current = map[k];
        if (current > max) {
            max = current;
        }
        if (current < min) {
            min = current;
        }
    }

    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);
        }
    }
}