#include <bits/stdc++.h>

using namespace std;

int n,x,a[100000005],raz1,suma;

int main(){

cin >> n >> x;

for ( int i=0;i<n;i++ ){
    cin >> a[i];
    sort(a+1,a+1+n);
    raz1=abs(a[0]-x);
    suma=abs(a[n]-a[0]);
}
    cout << raz1+suma << endl;

return 0;}