#include <bits/stdc++.h>
const int maxn = 2e5 + 10;
using namespace std;
long long n, cnt, invnum, num, t;
long long sum1[maxn], sum2[maxn], pos[maxn];
void updata(long long sum[], int i, int k) {
  while (i <= n) {
    sum[i] += k;
    i += ((i) & (-i));
  }
}
long long getsum(long long sum[], int i) {
  long long res = 0;
  while (i) {
    res += sum[i];
    i -= ((i) & (-i));
  }
  return res;
}
long long bs(long long le, long long ri, long long num) {
  long long mid;
  while (le <= ri) {
    mid = (le + ri) >> 1;
    if (getsum(sum1, mid) * 2 <= num) {
      le = mid + 1;
    } else
      ri = mid - 1;
  }
  return le;
}
signed main() {
  scanf("%lld", &n);
  invnum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &t);
    pos[t] = i;
  }
  for (int i = 1; i <= n; i++) {
    updata(sum1, pos[i], 1);
    invnum += (i - getsum(sum1, pos[i]));
    updata(sum2, pos[i], pos[i]);
    long long l = 1, r = n;
    long long mid = bs(l, r, i);
    long long ans = 0;
    cnt = getsum(sum1, mid);
    num = getsum(sum2, mid);
    ans += invnum;
    ans += mid * cnt - num - cnt * (cnt - 1) / 2;
    cnt = i - cnt;
    num = getsum(sum2, n) - num;
    ans += num - cnt * (mid + 1) - cnt * (cnt - 1) / 2;
    printf("%lld ", ans);
  }
  printf("\n");
  return 0;
}
