#include <bits/stdc++.h>
using namespace std;
vector<int> b, s;
bool cmp(int a, int b) { return a > b; }
int main() {
  int N, M, tmp;
  long long ans = 0;
  b.clear();
  s.clear();
  scanf("%d %d", &N, &M);
  for (int i = 0; i < N; i++) {
    scanf("%d", &tmp);
    if (tmp > M)
      b.push_back(tmp);
    else
      s.push_back(tmp);
  }
  sort(b.begin(), b.end(), cmp);
  sort(s.begin(), s.end());
  while (s.size() > (N >> 1)) {
    ans += M - s.back();
    s.pop_back();
  }
  while (b.size() > (N >> 1)) {
    ans += b.back() - M;
    b.pop_back();
  }
  printf("%lld\n", ans);
  return 0;
}
