#include <stdio.h>

int main()
{
    long long n,x;
    scanf("%lld%lld",&n,&x);
    long long a[n+10];
    for (long long i=0;i<n;i++) scanf("%lld",&a[i]);
    long long maxx=-1000000000,minn=1000000000;
    for (long long i=0;i<n;i++)
    {
        if (a[i]>maxx) maxx=a[i];
        if (a[i]<minn) minn=a[i];
    }
    if (minn>x) printf("%lld",maxx-x);
    else printf("%lld",(x-minn)+(maxx-minn));
    return 0;
}