#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 2 * 1e5 + 15;
int n;
int a[MAXN], loc[MAXN];
long long c_pos[MAXN], c_inv[MAXN];
set<int> st;
void add(long long c[], int x, int k) {
  for (int i = x; i <= n; i += ((i) & (-i))) c[i] += k;
}
long long query(long long c[], int x) {
  long long res = 0;
  for (int i = x; i >= 1; i -= ((i) & (-i))) res += c[i];
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    loc[a[i]] = i;
  }
  long long sum_inv = 0, res = 0;
  int mid = loc[1], cntl = 0, cntr = 0;
  for (int i = 1; i <= n; i++) {
    int pos = loc[i];
    add(c_inv, pos, 1);
    sum_inv += i - query(c_inv, pos);
    add(c_pos, pos, pos);
    st.insert(pos);
    if (pos > mid)
      cntr++;
    else if (pos < mid)
      cntl++;
    if (cntr - cntl > 1)
      mid = *st.upper_bound(mid), cntl++, cntr--;
    else if (cntl - cntr > 1)
      mid = *(--st.lower_bound(mid)), cntl--, cntr++;
    res = 1ll * (mid - cntl + mid - 1) * cntl / 2 -
          1ll * (mid + 1 + mid + cntr) * cntr / 2;
    res -= query(c_pos, mid - 1);
    res += query(c_pos, n) - query(c_pos, mid);
    printf("%lld ", sum_inv + res);
  }
  printf("\n");
  return 0;
}
