#include <bits/stdc++.h>
using namespace std;
void getint(int &v) {
  char ch, fu = 0;
  for (ch = '*'; (ch < '0' || ch > '9') && ch != '-'; ch = getchar())
    ;
  if (ch == '-') fu = 1, ch = getchar();
  for (v = 0; ch >= '0' && ch <= '9'; ch = getchar()) v = v * 10 + ch - '0';
  if (fu) v = -v;
}
int n, a[500010], w[500010], bit[500010];
long long BIT[500010], ans[500010];
int lowbit(int x) { return x & -x; }
int sum(int x) {
  int t = 0;
  for (; x; x -= lowbit(x)) t += bit[x];
  return t;
}
void add(int x) {
  int t = x;
  for (; x <= n; x += lowbit(x)) bit[x]++, BIT[x] += t;
}
long long SUM(int x) {
  long long t = 0;
  for (; x; x -= lowbit(x)) t += BIT[x];
  return t;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) getint(a[i]), w[a[i]] = i;
  for (int i = 1; i <= n; ++i) {
    ans[i] = ans[i - 1] + i - 1 - sum(w[i] - 1);
    add(w[i]);
  }
  memset(bit, 0, sizeof(bit));
  memset(BIT, 0, sizeof(BIT));
  for (int i = 1; i <= n; ++i) {
    add(w[i]);
    int l = 1, r = n;
    while (l < r) {
      int o = ((l + r) >> 1);
      if (sum(o) >= (i + 1) / 2)
        r = o;
      else
        l = o + 1;
    }
    int L = sum(r);
    long long t = SUM(r);
    ans[i] += 1ll * r * L - 1ll * L * (L - 1) / 2 - t;
    int R = i - L;
    ans[i] += (SUM(n) - t) - 1ll * r * R - 1ll * R * (R + 1) / 2;
    printf("%lld ", ans[i]);
  }
  return 0;
}
