#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int segtree[4 * maxn];
int a[maxn], ind[maxn];
void change(int index, int value, int ll, int rr, int cur) {
  if (ll > index || rr < index) return;
  if (ll == index && rr == index) {
    a[index] = segtree[cur] = value;
    return;
  }
  int mm = (ll + rr) / 2;
  change(index, value, ll, mm, 2 * cur + 1);
  change(index, value, mm + 1, rr, 2 * cur + 2);
  segtree[cur] = segtree[2 * cur + 1] + segtree[2 * cur + 2];
}
int getsumm(int l, int r, int ll, int rr, int cur) {
  if (l > r) return 0;
  if (ll >= l && rr <= r) return segtree[cur];
  if (ll > r || l > rr) return 0;
  int mm = (ll + rr) / 2;
  return getsumm(l, r, ll, mm, 2 * cur + 1) +
         getsumm(l, r, mm + 1, rr, 2 * cur + 2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int n2 = 1, ntmp = n;
  while (ntmp > 0) {
    ntmp /= 2;
    n2 *= 2;
  }
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    ind[p - 1] = i;
  }
  int median = -1;
  long long invs = 0;
  long long mediancost = 0;
  int medianmove = 0;
  for (int i = 0; i < n; i++) {
    change(ind[i], 1, 0, n2 - 1, 0);
    invs += getsumm(ind[i] + 1, n - 1, 0, n2 - 1, 0);
    if (median != -1)
      mediancost +=
          abs(ind[i] - median) + 1 -
          getsumm(min(ind[i], median), max(ind[i], median), 0, n2 - 1, 0);
    if (median == -1) {
      median = ind[i];
    } else if (ind[i] > median) {
      mediancost -= getsumm(ind[i] + 1, n - 1, 0, n2 - 1, 0);
      medianmove++;
    } else {
      mediancost -= getsumm(0, ind[i] - 1, 0, n2 - 1, 0);
      medianmove--;
    }
    if (medianmove / 2 != 0) {
      int cnt = 0, diff = medianmove / 2;
      while (true) {
        median += diff;
        if (a[median] == 1) break;
        cnt++;
      }
      mediancost -= cnt;
      medianmove = 0;
    }
    cout << mediancost + invs << " ";
  }
  return 0;
}
