#include <bits/stdc++.h>
using namespace std;
vector<int> sm, gr;
int main() {
  int n, s, a;
  long long ans = 0;
  scanf("%d %d", &n, &s);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if (a <= s)
      sm.push_back(a);
    else
      gr.push_back(a);
  }
  if ((int)sm.size() > (int)gr.size()) {
    sort(sm.begin(), sm.end());
    while ((int)sm.size() > n / 2) ans += s - sm.back(), sm.pop_back();
  } else {
    sort(gr.begin(), gr.end(), greater<int>());
    while ((int)gr.size() > n / 2) ans += gr.back() - s, gr.pop_back();
  }
  printf("%I64d\n", ans);
  return 0;
}
