#include <bits/stdc++.h>
using namespace std;
long long n, a[200005], pos[200005], t0[200005], t1[200005];
long long lowbit(long long x) { return x & (-x); }
long long fast_power(long long a, long long b) {
  long long x;
  for (x = 1; b; b >>= 1) {
    if (b & 1) x = 1ll * x * a % 1000000009;
    a = 1ll * a * a % 1000000009;
  }
  return x % 1000000009;
}
void update0(long long x, long long y) {
  long long i;
  for (i = x; i <= n; i += lowbit(i)) t0[i] += y;
}
void update1(long long x, long long y) {
  long long i;
  for (i = x; i <= n; i += lowbit(i)) t1[i] += y;
}
long long query0(long long x) {
  long long i, r = 0;
  for (i = x; i; i -= lowbit(i)) r += t0[i];
  return r;
}
long long query1(long long x) {
  long long i, r = 0;
  for (i = x; i; i -= lowbit(i)) r += t1[i];
  return r;
}
int main() {
  long long i, l, r, mid, s, r0, r1, l0, l1, s0, s1;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  r0 = 0;
  for (i = 1; i <= n; i++) {
    r0 += i - query0(pos[i]) - 1;
    update0(pos[i], 1);
    update1(pos[i], pos[i]);
    l = 1;
    r = n;
    while (l <= r) {
      mid = (l + r) / 2;
      if (query0(mid - 1) * 2 <= i) {
        s = mid;
        l = mid + 1;
      } else
        r = mid - 1;
    }
    l0 = query0(s);
    l1 = query1(s);
    r1 = l0 * s - l1 - l0 * (l0 - 1) / 2;
    s0 = i - l0;
    s1 = query1(n) - l1;
    r1 += s1 - s0 * s - s0 * (s0 + 1) / 2;
    cout << r0 + r1 << " ";
  }
  puts("");
  return 0;
}
