#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n;
int a[N], p[N];
long long s1, s2;
long long f[1 << 19], g[1 << 19];
void modify(int v, int l, int r, int x) {
  if (l == r) {
    f[v] = l, g[v] = 1;
    return;
  }
  int m = l + r >> 1;
  if (x <= m)
    modify(v + v, l, m, x);
  else
    modify(v + v + 1, m + 1, r, x);
  f[v] = f[v + v] + f[v + v + 1], g[v] = g[v + v] + g[v + v + 1];
}
long long query(int v, int l, int r, int x, int y, int t) {
  if (l == x & r == y) return t == 1 ? g[v] : f[v];
  int m = l + r >> 1;
  if (y <= m) return query(v + v, l, m, x, y, t);
  if (x > m) return query(v + v + 1, m + 1, r, x, y, t);
  return query(v + v, l, m, x, m, t) + query(v + v + 1, m + 1, r, m + 1, y, t);
}
int select(int v, int l, int r, int k) {
  if (l == r) return l;
  int m = l + r >> 1;
  if (g[v + v] >= k) return select(v + v, l, m, k);
  return select(v + v + 1, m + 1, r, k - g[v + v]);
}
long long sum(int x) { return 1ll * (x + 1) * x >> 1; }
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) scanf("%d", a + i), p[a[i]] = i;
  for (int i = (1); i <= (n); i++) {
    s1 += query(1, 1, n, p[i], n, 1);
    modify(1, 1, n, p[i]);
    int m = select(1, 1, n, i + 1 >> 1);
    long long t1 = m > 1 ? query(1, 1, n, 1, m - 1, 1) : 0;
    long long t2 = m < n ? query(1, 1, n, m + 1, n, 1) : 0;
    long long c1 = m > 1 ? query(1, 1, n, 1, m - 1, 2) : 0;
    long long c2 = m < n ? query(1, 1, n, m + 1, n, 2) : 0;
    s2 = m * t1 - c1 - sum(t1) + c2 - sum(t2) - m * t2;
    printf("%lld ", s1 + s2);
  }
}
