#include <bits/stdc++.h>

using namespace std;

int n,x;

int main () {
    cin >> n >> x;

    int a[n+5];

    for (int i=1; i<=n; i++) {

    cin >> a[i]; }

    long long p=100000000;
    long long s=-100000000;

    for (int i=1; i<=n; i++) {
    if (a[i]>s) s=a[i];
    if (a[i]<p) p=a[i];}

    if (n>=2) {
        if (x>s)
        cout << x-s <<endl;
        else cout << s-x << endl;}

    else if (x>s)
    cout << x-p << endl;
    if (x>p and x<s)
    cout << x-p+s-x << endl;
    if (x<p)
    cout << s-x << endl;


return 0;
}