#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
int a[N], pos[N];
long long tree1[N], tree2[N];
int n;
void add(long long tree[], int x, int val) {
  while (x <= n) {
    tree[x] += val;
    x += x & -x;
  }
}
long long query(long long tree[], int x) {
  long long res = 0;
  while (x > 0) {
    res += tree[x];
    x -= x & -x;
  }
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    pos[a[i]] = i;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += i - 1 - query(tree1, pos[i]);
    add(tree1, pos[i], 1);
    add(tree2, pos[i], pos[i]);
    int l = 1, r = n, tmp = 0;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (query(tree1, mid) * 2 <= i) {
        l = mid + 1;
        tmp = mid;
      } else {
        r = mid - 1;
      }
    }
    long long cnt = query(tree1, tmp);
    long long sum = query(tree2, tmp);
    long long tmpans = tmp * cnt - sum - (cnt - 1) * cnt / 2;
    cnt = i - cnt, sum = query(tree2, n) - sum;
    tmpans += sum - cnt * (tmp + 1) - cnt * (cnt - 1) / 2;
    printf("%lld ", ans + tmpans);
  }
  puts("");
  return 0;
}
