#include <bits/stdc++.h>
using namespace std;
const int MX = 200005;
int p[MX];
int pos[MX];
int fwt[MX];
void fwt_add(int i, int d) {
  while (i < MX) {
    fwt[i] += d;
    i += i & -i;
  }
}
int fwt_get(int i) {
  int s = 0;
  while (i) {
    s += fwt[i];
    i -= i & -i;
  }
  return s;
}
int cnt[MX];
int main() {
  int n;
  ignore = scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    ignore = scanf("%d", p + i);
    pos[p[i]] = i;
  }
  for (int i = n; i >= 1; i--) {
    cnt[p[i]] = fwt_get(p[i]);
    fwt_add(p[i], 1);
  }
  long long pref_sum = 0;
  set<int> L, R;
  long long sum_L = 0, sum_R = 0;
  for (int i = 1; i <= n; i++) {
    pref_sum += cnt[i];
    if (R.empty() || pos[i] < *R.begin()) {
      L.insert(pos[i]);
      sum_L += pos[i];
    } else {
      R.insert(pos[i]);
      sum_R += pos[i];
    }
    while (L.size() < R.size()) {
      int x = *R.begin();
      R.erase(x);
      sum_R -= x;
      L.insert(x);
      sum_L += x;
    }
    while (L.size() - 1 > R.size()) {
      int x = *prev(L.end());
      L.erase(x);
      sum_L -= x;
      R.insert(x);
      sum_R += x;
    }
    long long cl = L.size();
    long long cr = R.size() + 1;
    int med = *prev(L.end());
    long long ans = cl * med - sum_L - cl * (cl - 1) / 2;
    ans +=
        cr * (n + 1 - med) - ((n + 1) * cr - sum_R - med) - cr * (cr - 1) / 2;
    ans += pref_sum;
    printf("%lld\n", ans);
  }
}
