#include <bits/stdc++.h>

using namespace std;


// global variables:
int N, X;  // N - # of neihbours, X - coo. of Milosh's house
int MAX_ABS_DIST_LEFT, MAX_ABS_DIST_RIGHT;


// functions:
void input();
void Solve();
void output(int out);



int main()
{
    //freopen("input.txt", "r", stdin);

    input();
    Solve();

    return 0;
}



void Solve() {
    int out = 0;

    if (MAX_ABS_DIST_LEFT < 0 || MAX_ABS_DIST_RIGHT < 0) {  // all neighbours are on one side of X
        out = max(MAX_ABS_DIST_LEFT, MAX_ABS_DIST_RIGHT);
    } else {  // do closer side first, come back and do further side
        out = 2 * (min(MAX_ABS_DIST_LEFT, MAX_ABS_DIST_RIGHT)) + max(MAX_ABS_DIST_LEFT, MAX_ABS_DIST_RIGHT);
    }

    output(out);
}


void input() {
    scanf("%d %d", &N, &X);
    MAX_ABS_DIST_LEFT = MAX_ABS_DIST_RIGHT = -1;

    for (int i = 0, cur_coo; i < N; ++i) {
        scanf("%d", &cur_coo);
        int cur_dist = abs(X - cur_coo);

        if (cur_coo < X) {
            MAX_ABS_DIST_LEFT = max(cur_dist, MAX_ABS_DIST_LEFT);
        } else {
            MAX_ABS_DIST_RIGHT = max(cur_dist, MAX_ABS_DIST_RIGHT);
        }
    }
}


void output(int out) {
    printf("%d\n", out);
}