#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000;
int a[200005], pos[200005];
int sum1[200005], sum2[200005];
void add(int *sum1, int x, int val) {
  while (x <= maxn) {
    sum1[x] += val;
    x += x & (-x);
  }
}
int sum(int *sum1, int pos) {
  int res = 0;
  while (pos) {
    res += sum1[pos];
    pos -= pos & (-pos);
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  int ans1 = 0, ans2 = 0;
  for (int i = 1; i <= n; i++) {
    ans1 += i - 1 - sum(sum1, pos[i]);
    add(sum1, pos[i], 1);
    add(sum2, pos[i], pos[i]);
    int l = 1, r = n;
    while (l < r) {
      int mid = l + r + 1 >> 1;
      if (sum(sum1, mid) * 2 <= i) {
        l = mid;
      } else
        r = mid - 1;
    }
    int cnt = sum(sum1, l);
    int sum3 = sum(sum2, l);
    ans2 = 0;
    ans2 += cnt * l - sum3 - cnt * (cnt - 1) / 2;
    cnt = i - cnt;
    sum3 = sum(sum2, n) - sum(sum2, l);
    ans2 += sum3 - cnt * (l + 1) - cnt * (cnt - 1) / 2;
    cout << ans1 + ans2 << " ";
  }
  cout << endl;
}
