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

#define ll long long


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

int main()
{
	ll int n,x;
	scanf("%lli %lli", &n, &x);
	ll int k[n];
	ll int temp;
	ll int rez;
	for (ll int i = 0; i < n; ++i)
	{
		scanf("%lli", &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("%lli\n", rez);

	return 0;
}