#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target( \
    "avx,avx2,fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long MOD = 1e9 + 7;
long long INF = 1e18;
string s;
const int N = 500000;
long long tr[N];
void inc(long long i, long long x) {
  for (; i < N; i = ((i + 1) | i)) {
    tr[i] += x;
  }
}
long long sm(long long i) {
  long long ans = 0;
  for (; i > -1; i = ((i + 1) & i) - 1) {
    ans += tr[i];
  }
  return ans;
}
long long tr2[N];
void inc2(long long i, long long x) {
  for (; i < N; i = ((i + 1) | i)) {
    tr2[i] += x;
  }
}
long long sm2(long long i) {
  long long ans = 0;
  for (; i > -1; i = ((i + 1) & i) - 1) {
    ans += tr2[i];
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),
      cout << fixed << setprecision(20);
  long long n;
  cin >> n;
  vector<long long> p(n);
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
    a[p[i]] = i;
  }
  vector<long long> ans(n);
  long long mx = a[0];
  long long mn = a[0];
  set<long long> lf;
  lf.insert(a[0]);
  set<long long> rt;
  inc(a[0], 1);
  inc2(a[0], 1);
  for (int k = 1; k < n; k++) {
    long long an = ans[k - 1];
    an += k - sm(a[k]);
    inc(a[k], 1);
    long long me = sm(a[k]) - 1;
    an -= min(me, k - me);
    {
      auto it = lf.end();
      it--;
      if (*it < a[k]) {
        rt.insert(a[k]);
      } else {
        lf.insert(a[k]);
      }
      if (lf.size() > rt.size() + 1) {
        it = lf.end();
        it--;
        rt.insert(*it);
        lf.erase(it);
      }
      if (lf.size() < rt.size()) {
        it = rt.begin();
        lf.insert(*it);
        rt.erase(it);
      }
    }
    auto it = lf.end();
    it--;
    long long med = *it;
    if (lf.size() == rt.size()) {
      if (a[k] <= med) {
        it = rt.begin();
        med = *it;
      }
    }
    long long kol = 0;
    inc2(a[k], 1);
    if (a[k] > med) {
      kol = (a[k] - med) - (sm2(a[k]) - sm2(med));
    } else {
      kol = (med - a[k]) - (sm2(med) - sm2(a[k]));
    }
    an += kol;
    ans[k] = an;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
}
