#include <bits/stdc++.h>
using namespace std;
int n, a[200007], pos[200007], c[200007];
priority_queue<int, vector<int>, less<int> > q1;
priority_queue<int, vector<int>, greater<int> > q2;
int ask(int p) {
  int res = 0;
  for (int i = p; i; i -= ((i) & (-i))) {
    res += c[i];
  }
  return res;
}
void add(int p) {
  for (int i = p; i <= n; i += ((i) & (-i))) {
    c[i]++;
  }
  return;
}
long long work(int num) {
  int p = pos[num];
  static long long sum1 = 0, sum2 = 0;
  if (q1.empty() || p < q1.top()) {
    q1.push(p);
    sum1 += p;
    while (q2.size() < num / 2) {
      q2.push(q1.top());
      sum2 += q1.top();
      sum1 -= q1.top();
      q1.pop();
    }
  } else {
    q2.push(p);
    sum2 += p;
    while (q2.size() > num / 2) {
      q1.push(q2.top());
      sum1 += q2.top();
      sum2 -= q2.top();
      q2.pop();
    }
  }
  static long long sum = 0;
  sum += ask(n - p + 1);
  add(n - p + 1);
  long long l = (long long)q1.top() * (long long)q1.size() - sum1 -
                (0 + (long long)q1.size() - 1) * (long long)q1.size() / 2;
  long long r = sum2 - (long long)q1.top() * (long long)q2.size() -
                (1 + (long long)q2.size()) * (long long)q2.size() / 2;
  return sum + l + r;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    pos[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    printf("%lld ", work(i));
  }
  return 0;
}
