#include <stdio.h>
#include <stdlib.h>
#define DIM 100000

int main()
{
    int a[DIM], i, ind=0, max, min, q, n, x;

    scanf("%d%d", &n, &x);
    for(i=0;i<n;i++)
    {
        scanf("%d", &a[i]);
        if(ind==0)
        {
            max=a[0];
            min=a[0];
        }
        if(max<a[i]) max=a[i];
        if(min>a[i]) min=a[i];
    }
    if(x-min>0) q=(x-min)+(max-min);
    else q= max-x;

    printf("%d", q);


    return 0;
}