#include<stdio.h>
long long n,x,a[1000000],max,min,s,l;
int main(){
	scanf("%lld %lld",&n,&x);
	for(int i=0;i<n;i++)scanf("%lld",&a[i]);
	max=min=a[0];
	for(int i=0;i<n;i++){
		if(a[i]>max)max=a[i];
		if(a[i]<min)min=a[i];
	}
	s=max-min;
	if(s<0)s*=-1;
	if(min<x)l=x-min;
	else l=min-x;
	if(l<0)l*=-1;
	s+=l;	
	printf("%lld",s);
	return 0;
}