#include <bits/stdc++.h>
using namespace std;
long long n, zo, a[500010], b[500010], f[500010], g[500010];
long long lowbit(long long x) { return x & (-x); }
void ins(long long x) {
  long long i;
  for (i = x; i <= n; i += lowbit(i)) f[i]++;
}
long long query(long long x) {
  long long xlh = 0, i;
  for (i = x; i; i -= lowbit(i)) xlh += f[i];
  return xlh;
}
void cha(long long x) {
  long long i;
  for (i = x; i <= n; i += lowbit(i)) g[i] += x;
}
long long get(long long x) {
  long long i, xlh = 0;
  for (i = x; i; i -= lowbit(i)) xlh += g[i];
  return xlh;
}
int main() {
  long long i, l, r, mid, ans, mx;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    b[a[i]] = i;
  }
  for (i = 1; i <= n; i++) {
    zo += query(n) - query(b[i]);
    ins(b[i]);
    cha(b[i]);
    l = 1;
    r = n;
    mx = 0;
    while (l <= r) {
      mid = (l + r) / 2;
      if (query(mid) < (i + 1) / 2)
        mx = mid, l = mid + 1;
      else
        r = mid - 1;
    }
    mx++;
    ans = 0;
    mid = (i + 1) / 2;
    ans -= get(mx - 1);
    ans += get(n) - get(mx);
    ans -= (mid - 1) * mid;
    ans += mid * (mid - 1) / 2;
    ans -= (mid + 1 + i) * (i - mid) / 2;
    ans += mid * (i - mid);
    ans += mx * (mid - 1 - i + mid);
    printf("%lld ", zo + ans);
  }
}
