#include <stdio.h>
#include <cmath>

int main()
{
    int n;
    int x;

    scanf("%d %d", &n, &x);

    int min = 0;
    int max  = 0;

    for(int i = 0; i<n; i++) {
        int  num;
        scanf("%d", &num);

        num = num - x;

        if(num < min) min = num;
        if(num > max) max = num;

    }

    int ldist = std::abs(min);
    int rdist = std::abs(max);

    if(ldist <= rdist) {
        printf("%d", 2*ldist + rdist);
    } else if (ldist > rdist) {
        printf("%d", ldist + 2*rdist);
    }
    return 0;
}