#include <bits/stdc++.h>
using namespace std;
char buf[1 << 21], *p1 = buf, *p2 = buf;
inline int qread() {
  register char c =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
           ? EOF
           : *p1++);
  register int x = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
             ? EOF
             : *p1++);
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - 48;
    c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
             ? EOF
             : *p1++);
  }
  return x * f;
}
inline int Abs(const int& x) { return (x > 0 ? x : -x); }
inline int Max(const int& x, const int& y) { return (x > y ? x : y); }
inline int Min(const int& x, const int& y) { return (x < y ? x : y); }
struct Segtree {
  long long sumv[800005], sumidx[800005];
  inline void Modify(int p, int pl, int pr, int id) {
    if (pl == pr) {
      sumv[p]++;
      sumidx[p] += id;
      return;
    }
    int mid = pl + pr >> 1;
    if (mid >= id)
      Modify(p << 1, pl, mid, id);
    else
      Modify(p << 1 | 1, mid + 1, pr, id);
    sumv[p] = sumv[p << 1] + sumv[p << 1 | 1];
    sumidx[p] = sumidx[p << 1] + sumidx[p << 1 | 1];
  }
  inline int Kth(int p, int pl, int pr, int k) {
    if (pl == pr) return pl;
    int mid = pl + pr >> 1;
    if (k <= sumv[p << 1])
      return Kth(p << 1, pl, mid, k);
    else
      return Kth(p << 1 | 1, mid + 1, pr, k - sumv[p << 1]);
  }
  inline long long Sumv(int p, int pl, int pr, int l, int r) {
    if (l > r) return 0;
    if (pl == l && pr == r) return sumv[p];
    int mid = pl + pr >> 1;
    if (mid >= r)
      return Sumv(p << 1, pl, mid, l, r);
    else if (mid + 1 <= l)
      return Sumv(p << 1 | 1, mid + 1, pr, l, r);
    else
      return Sumv(p << 1, pl, mid, l, mid) +
             Sumv(p << 1 | 1, mid + 1, pr, mid + 1, r);
  }
  inline long long Sumidx(int p, int pl, int pr, int l, int r) {
    if (l > r) return 0;
    if (pl == l && pr == r) return sumidx[p];
    int mid = pl + pr >> 1;
    if (mid >= r)
      return Sumidx(p << 1, pl, mid, l, r);
    else if (mid + 1 <= l)
      return Sumidx(p << 1 | 1, mid + 1, pr, l, r);
    else
      return Sumidx(p << 1, pl, mid, l, mid) +
             Sumidx(p << 1 | 1, mid + 1, pr, mid + 1, r);
  }
};
Segtree sgt;
int n, a[200005], idx[200005];
inline void Read() {
  n = qread();
  for (int i = 1; i <= n; i++) idx[a[i] = qread()] = i;
}
inline long long Sum(int l, int k) { return 1ll * k * (l + l + k - 1) / 2; }
inline void Solve() {
  long long inv = 0;
  for (int i = 1; i <= n; i++) {
    inv += sgt.Sumv(1, 1, n, idx[i] + 1, n);
    sgt.Modify(1, 1, n, idx[i]);
    int midv = sgt.Kth(1, 1, n, i + 1 >> 1);
    long long lsum = sgt.Sumidx(1, 1, n, 1, midv - 1),
              rsum = sgt.Sumidx(1, 1, n, midv + 1, n);
    printf("%lld ", inv + Sum(midv - (i - 1 >> 1), i - 1 >> 1) - lsum + rsum -
                        Sum(midv + 1, i >> 1));
  }
}
int main() {
  Read();
  Solve();
  return 0;
}
