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