#include <bits/stdc++.h>
using namespace std;
const int mxn = 2e5 + 100;
int idx[mxn], bit[mxn];
long long s1, s2;
priority_queue<int, vector<int>, greater<int>> q;
priority_queue<int> p;
long long sum(int n) { return 1LL * n * (n + 1) / 2; }
void add(const int &x) {
  for (int idx = x; idx < mxn; idx += idx & -idx) bit[idx]++;
  if (p.empty())
    p.push(x), s1 += x;
  else {
    if (x < p.top())
      p.push(x), s1 += x;
    else
      q.push(x), s2 += x;
    if (p.size() - q.size() == 2) {
      s1 -= p.top(), s2 += p.top();
      q.push(p.top()), p.pop();
    }
    for (; q.size() > p.size();) {
      s1 += q.top(), s2 -= q.top();
      p.push(q.top()), q.pop();
    }
  }
}
int ask(int idx) {
  int ret = 0;
  for (; idx > 0; idx -= idx & -idx) ret += bit[idx];
  return ret;
}
long long query() {
  const int sz1 = (int)p.size();
  const int sz2 = (int)q.size();
  const int m = (int)p.top() - sz1;
  long long ret = 1LL * m * sz1 - (s1 - sum(sz1));
  ret += s2 - (sum(sz1 + sz2) - sum(sz1)) - 1LL * m * sz2;
  return ret;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1, x; i <= n; ++i) scanf("%d", &x), idx[x] = i;
  long long tt_inv = 0;
  for (int i = 1; i <= n; ++i) {
    add(idx[i]);
    tt_inv += i - ask(idx[i]);
    query();
    printf("%lld ", tt_inv + query());
  }
}
