#include <bits/stdc++.h>

using namespace std;

int getClosest(vector<int>, int, int, int); 
  
int findClosest(vector<int> arr, int n, int target) 
{  
    if (target <= arr[0]) 
        return 0; 
    if (target >= arr[n - 1]) 
        return n - 1; 
  
    int i = 0, j = n, mid = 0; 
    while (i < j) { 
        mid = (i + j) / 2; 
  
        if (arr[mid] == target) 
            return mid; 
  
        if (target < arr[mid]) { 
  
            if (mid > 0 && target > arr[mid - 1]) 
                return getClosest(arr, mid - 1, mid, target); 
  
            j = mid; 
        } 
  
        else { 
            if (mid < n - 1 && target < arr[mid + 1]) 
                return getClosest(arr, mid, mid + 1, target); 
            i = mid + 1;  
        } 
    } 
  
    return mid; 
} 
  
int getClosest(vector<int> arr, int val1, int val2, 
               int target) 
{ 
    if (target - arr[val1] >= arr[val2] - target) 
        return val2; 
    else
        return val1; 
} 

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int n, x, e;
    cin >> n >> x;
    long res = 0;

    vector<int> a;

    for (int i = 0; i < n; ++i) {
        cin >> e;
        a.emplace_back(e);
    }

    sort(a.begin(), a.end());
    
    while (a.size()) {
        e = findClosest(a, n, x);
        res += abs(x - a[e]);
        x = a[e];
        a.erase(a.begin() + e);
        --n;
    }

    cout << res;
}