#include <bits/stdc++.h>
using  namespace std;
int s[1000001];
int main() {

int n,y,p,g,g1;
cin >> n >> y;

p = 0;

for( int x = 1 ; x <= n ; x++ )
{
    cin >> s[x];
    if(s[x] < y ) p++;
}

g = s[1];g1 = s[1];


for( int x = 1 ; x <= n ; x++ )
{
    g = min(g , s[x]);
    g1 = max( g1 , s[x]);
}


if( p == n ) cout << abs(g - y);
    else cout << g1 - y;






return 0;
}