#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void BubbleSort(short int a[], short int n){
   short int i, j;
   for (i = 0; i < n-1; i++)
       for (j = 0; j < n-i-1; j++)
           if (a[j] > a[j+1])
              swap(&a[j], &a[j+1]);
}

void swap(short int *xp, short int *yp){
    short int temp = *xp;
    *xp = *yp;
    *yp = temp;
}

int main(){

    short int n,x,a[1000000],i,broj;
    do{
        scanf("%hi %hi",&n,&x);
    }while (1>n || n>1000000 || -100000000>x || x>100000000);
    for(i=0; i<n; i++){
        scanf("%hi",&a[i]);
    }
    BubbleSort(a,n);
    broj = 0;
    switch(abs(x-a[0]) > abs(x-a[n-1])){
        case 1:
            broj = abs(x-a[n-1]);
            break;
        case 0:
            broj = abs(x-a[0]);
            break;
    }
    broj += abs(a[n-1]-a[0]);
    printf("%hi",broj);
}