#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 200005;
long long n;
long long a[MAXN], pos[MAXN];
struct BIT {
  vector<long long> bit;
  long long n;
  BIT() {}
  BIT(long long N) {
    n = N;
    bit.resize(n + 1);
  }
  void upd(long long i, long long val) {
    for (; i <= n; i += (i & (-i))) bit[i] += val;
  }
  long long sum(long long i) {
    long long s = 0;
    for (; i > 0; i -= (i & (-i))) s += bit[i];
    return s;
  }
  long long sum(long long l, long long r) {
    if (l > r) return 0;
    return sum(r) - sum(l - 1);
  }
};
struct segtree {
  vector<long long> IT, lazy;
  long long n;
  segtree() {}
  segtree(long long N) {
    n = N;
    IT.resize(4 * n + 1);
    lazy.resize(4 * n + 1);
  }
  void push(long long id, long long l, long long r) {
    IT[id] += lazy[id] * (r - l + 1);
    if (l != r) {
      lazy[id * 2] += lazy[id];
      lazy[id * 2 + 1] += lazy[id];
    }
    lazy[id] = 0;
  }
  void upd(long long u, long long v, long long val, long long id, long long l,
           long long r) {
    push(id, l, r);
    if (r < u || l > v) return;
    if (l >= u && r <= v) {
      lazy[id] += val;
      push(id, l, r);
      return;
    }
    long long mid = (l + r) / 2;
    upd(u, v, val, id * 2, l, mid);
    upd(u, v, val, id * 2 + 1, mid + 1, r);
    IT[id] = IT[id * 2] + IT[id * 2 + 1];
  }
  void upd(long long u, long long v, long long val) { upd(u, v, val, 1, 1, n); }
  long long sum(long long u, long long v, long long id, long long l,
                long long r) {
    push(id, l, r);
    if (r < u || l > v) return 0;
    if (l >= u && r <= v) return IT[id];
    long long mid = (l + r) / 2;
    return sum(u, v, id * 2, l, mid) + sum(u, v, id * 2 + 1, mid + 1, r);
  }
  long long sum(long long u, long long v) { return sum(u, v, 1, 1, n); }
};
long long fsum(long long l, long long r) {
  return r * (r + 1) / 2 - (l - 1) * l / 2;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  BIT bit(n);
  segtree exl(n), exr(n);
  for (long long i = 1; i <= n; i++) cin >> a[i], pos[a[i]] = i;
  long long inv = 0, mn = 1e9, mx = -1e9;
  for (long long i = 1; i <= n; i++) {
    inv += bit.sum(pos[i], n);
    bit.upd(pos[i], 1);
    mn = min(mn, pos[i]);
    mx = max(mx, pos[i]);
    exl.upd(pos[i], n, 1);
    exr.upd(1, pos[i], 1);
    long long f = (i) / 2;
    long long l = mn, r = mx;
    while (l < r) {
      long long mid = (l + r + 1) / 2;
      if (bit.sum(mn, mid) > f)
        r = mid - 1;
      else
        l = mid;
    }
    long long cnts = exl.sum(mn, l) - fsum(1, f), cnte = 0;
    if (l + 1 <= mx) cnte = exr.sum(l + 1, mx) - fsum(1, i - f);
    if (i == 1)
      cout << "0 ";
    else
      cout << inv + cnts + cnte << ' ';
  }
}
