#include <stdio.h>
#include <stdlib.h>

int comp(const void *a,const void *b) {
int *x = (int *) a;
int *y = (int *) b;
return *x - *y;
}

int main()
{
	int n,x;
	scanf("%i %i", &n, &x);
	int k[n];
	int temp;
	int rez;
	for (int i = 0; i < n; ++i)
	{
		scanf("%i", &k[i]);
	}
	qsort(k, n, sizeof(*k), comp);

	if(x>k[n-1])
	{
		rez = abs(k[0]-x);
	}
	else if (x<k[0])
	{
		rez = abs(k[n-1]-x);
	}

	printf("%i\n", rez);

	return 0;
}