#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 10;
int n, a[N], p[N];
long long s1[N], s2[N];
int lowbit(int x) { return x & -x; }
void add(long long* sum, int x, int b) {
  for (int i = x; i <= n; i += lowbit(i)) {
    sum[i] += b;
  }
}
long long query(long long* sum, int r) {
  long long ans = 0;
  for (int i = r; i > 0; i -= lowbit(i)) {
    ans += sum[i];
  }
  return ans;
}
long long ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    p[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    add(s1, p[i], 1);
    add(s2, p[i], p[i]);
    ans += 1ll * i - query(s1, p[i]);
    int L = 1, R = n;
    while (L < R) {
      int mid = L + R + 1 >> 1;
      if (query(s1, mid - 1) * 2 <= i)
        L = mid;
      else
        R = mid - 1;
    }
    long long aa = 1ll * i / 2, bb = 1ll * i - 1ll * i / 2 - 1ll;
    long long sum = (2 * L - aa - 1) * aa / 2 - query(s2, L - 1);
    sum += query(s2, n) - query(s2, L) - (2 * L + bb + 1) * bb / 2;
    printf("%lld%s", ans + sum, i == n ? "\n" : " ");
  }
  return 0;
}
