#include <bits/stdc++.h>
using namespace std;
const long long maxn = 3e5 + 7, mod = 1e9 + 7, MAXN = 1e6 + 7;
const double eps = 1e-9;
const long long inf = 1e18;
mt19937 rnd(time(0));
struct Tree {
  long long len = 1;
  vector<long long> tree;
  void build(long long siz = maxn) {
    while (len < siz) len <<= 1;
    tree.resize(len + len - 1);
  }
  long long sum(long long l1, long long r1, long long l = 0, long long r = -1,
                long long rt = 0) {
    if (r == -1) r = len - 1;
    if (l >= l1 && r <= r1) {
      return tree[rt];
    }
    if (max(l, l1) > min(r, r1)) return 0;
    long long t = (l + r) / 2;
    return sum(l1, r1, l, t, rt * 2 + 1) + sum(l1, r1, t + 1, r, rt * 2 + 2);
  }
  void upd(long long id, long long x, long long l = 0, long long r = -1,
           long long rt = 0) {
    if (r == -1) r = len - 1;
    if (l == id && r == id) {
      tree[rt] = x;
      return;
    }
    if (l > id || r < id) return;
    long long t = (l + r) / 2;
    upd(id, x, l, t, rt * 2 + 1);
    upd(id, x, t + 1, r, rt * 2 + 2);
    tree[rt] = tree[rt * 2 + 1] + tree[rt * 2 + 2];
  }
  long long get(long long k, long long l = 0, long long r = -1,
                long long rt = 0) {
    if (r == -1) r = len - 1;
    if (l == r) return l;
    long long L = rt * 2 + 1;
    long long R = rt * 2 + 2;
    long long t = (l + r) / 2;
    if (tree[L] >= k) {
      return get(k, l, t, L);
    }
    return get(k - tree[L], t + 1, r, R);
  }
};
Tree SUM, one;
long long n;
long long rp[maxn];
long long p[maxn];
void solve() {
  SUM.build();
  one.build();
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> p[i];
    rp[p[i]] = i;
  }
  long long inv = 0;
  for (long long i = 1; i <= n; ++i) {
    one.upd(rp[i], 1);
    inv += one.sum(rp[i] + 1, one.len - 1);
    SUM.upd(rp[i], rp[i]);
    long long mid = (i + 1) / 2;
    long long idx = one.get(mid);
    long long add = idx * (mid - 1) - SUM.sum(0, idx - 1) - mid * (mid - 1) / 2;
    add += SUM.sum(idx + 1, SUM.len - 1) - idx * (i - mid) -
           (i - mid) * (i - mid + 1) / 2;
    cout << inv + add << " ";
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  cout << fixed;
  long long t = 1;
  for (long long i = 0; i < t; ++i) {
    solve();
  }
  return 0;
}
