#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const int p = 1000000009;
int lowbit(int x) { return x & (-x); }
int fast_power(int a, int b) {
  int x;
  for (x = 1; b; b >>= 1) {
    if (b & 1) x = 1ll * x * a % p;
    a = 1ll * a * a % p;
  }
  return x % p;
}
int n;
int a[200005], pos[200005];
long long tree0[200005], tree1[200005];
void update0(int x, int y) {
  for (int i = x; i <= n; i += lowbit(i)) tree0[i] += y;
}
void update1(int x, int y) {
  for (int i = x; i <= n; i += lowbit(i)) tree1[i] += y;
}
long long query0(int x) {
  long long res = 0;
  for (int i = x; i > 0; i -= lowbit(i)) res += tree0[i];
  return res;
}
long long query1(int x) {
  long long res = 0;
  for (int i = x; i > 0; i -= lowbit(i)) res += tree1[i];
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    pos[a[i]] = i;
  }
  long long res0 = 0;
  for (int i = 1; i <= n; i++) {
    res0 += i - 1 - query0(pos[i]);
    update0(pos[i], 1);
    update1(pos[i], pos[i]);
    int l = 1, r = n, s;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (query0(mid - 1) * 2 <= i) {
        s = mid;
        l = mid + 1;
      } else
        r = mid - 1;
    }
    long long left_sum0 = query0(s), left_sum1 = query1(s);
    long long res1 =
        left_sum0 * s - left_sum1 - left_sum0 * (left_sum0 - 1) / 2;
    long long right_sum0 = i - left_sum0, right_sum1 = query1(n) - left_sum1;
    res1 += right_sum1 - right_sum0 * s - right_sum0 * (right_sum0 + 1) / 2;
    printf("%lld ", res0 + res1);
  }
  puts("");
  return 0;
}
