#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int idx[N];
long long cnt[2][N];
void add(long long *cnt, int pos, int num) {
  for (; pos <= N; pos += pos & -pos) cnt[pos] += num;
}
long long query(long long cnt[], int pos) {
  long long res = 0;
  for (; pos; pos -= pos & -pos) res += cnt[pos];
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    idx[x] = i;
  }
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    add(cnt[0], idx[i], 1);
    add(cnt[1], idx[i], idx[i]);
    res += i - query(cnt[0], idx[i]);
    long long ans, l = 1, r = n;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (query(cnt[0], mid) >= (i + 1) / 2)
        ans = mid, r = mid - 1;
      else
        l = mid + 1;
    }
    long long c1 = query(cnt[0], ans), c2 = i - c1;
    long long q1 = query(cnt[1], ans), q2 = query(cnt[1], n) - q1;
    cout << res + (ans * 2 - c1 + 1) * c1 / 2 - q1 + q2 -
                (ans * 2 + c2 + 1) * c2 / 2
         << ' ';
  }
  cout << endl;
  return 0;
}
