#include <iostream>
using namespace std;

int main(){
    int n, x;
    cin >> n >> x;
    int a[n];
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    int maximum = 0;
    int xminusa;
    int geta = 0;
    for (int i = 0; i < n; ++i){
        xminusa = x - a[i];
        if (xminusa < 0)
            xminusa = -(xminusa);
        if (maximum < xminusa){
            maximum = xminusa;
            geta = i;
        }
    }

    int drugastrana = 0;
    if (x < a[geta]){
        for (int i = 0; i < n; ++i){
            if (a[i] < x){
                xminusa = x - a[i];
                if (xminusa < 0)
                    xminusa = -xminusa;
                if (drugastrana < xminusa)
                    drugastrana = xminusa;
            }
        }
    } else {
        for (int i = 0; i < n; ++i){
            if (a[i] > x){
                xminusa = x - a[i];
                if (xminusa < 0)
                    xminusa = -xminusa;
                if (drugastrana < xminusa)
                    drugastrana = xminusa;
            }
        }
    }

    cout << 2*drugastrana + maximum;

    return 0;
}