#include<stdio.h>
#include<time.h>
#include<stdlib.h>
#include<conio.h>
#include<cmath>

main()
{
	int a[100],n,x,i,j,temp,brojac1=0,brojac2=0,k;
	scanf("%d%d",&n,&x);
	if(n<=10) {
		for(i=1;i<=n;i++) {
			scanf("%d",&a[i]);
		}
		for(i=1;i<=n;i++) {
			for(j=i+1;j<n+1;j++) {
				if(a[j]<a[i]) {
					temp=a[i];
					a[i]=a[j];
					a[j]=temp;
				}
			}
		}
		if(n==0) {
			return 0;
		}
		else if(n==1) {
			printf("%d",abs(x-a[1]));
		}
		else if(x<a[1]) {
			printf("%d",abs(x-a[n]));
		}
		else if(x>a[n]) {
			printf("%d",abs(x-a[1]));
		}
		else if(abs(x-a[1])<abs(x-a[n])) {
			brojac1=brojac1+abs(x-a[1]);
			k=a[1];
			while(k<a[n]) {
				brojac2++;
				k++;
			}
			printf("%d",brojac1+brojac2);
		}
		else if(abs(x-a[n])<abs(x-a[1])) {
			brojac1=brojac1+abs(x-a[n]);
			k=a[1];
			while(k<a[n]) {
				brojac2++;
				k++;
			}
			printf("%d",brojac1+brojac2);
		}
	}
	else return 0;
}