#include <bits/stdc++.h>
using namespace std;
int n;
vector<long long> res, t, ts;
vector<pair<long long, long long>> p;
long long qry1(int v, int tl, int tr, int l, int r) {
  if (l > r) return 0;
  if (tl == l && tr == r) {
    return t[v];
  }
  int tm = (tl + tr) / 2;
  return qry1(v * 2, tl, tm, l, min(tm, r)) +
         qry1(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
}
void upd1(int v, int tl, int tr, int u, int x) {
  if (tl == tr)
    t[v] = x;
  else {
    int tm = (tl + tr) / 2;
    if (u > tm)
      upd1(v * 2 + 1, tm + 1, tr, u, x);
    else
      upd1(v * 2, tl, tm, u, x);
    t[v] = t[v * 2] + t[v * 2 + 1];
  }
}
long long qry2(int v, int tl, int tr, int l, int r) {
  if (l > r) return 0;
  if (tl == l && tr == r) {
    return ts[v];
  }
  int tm = (tl + tr) / 2;
  return qry2(v * 2, tl, tm, l, min(tm, r)) +
         qry2(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
}
void upd2(int v, int tl, int tr, int u, int x) {
  if (tl == tr)
    ts[v] = x;
  else {
    int tm = (tl + tr) / 2;
    if (u > tm)
      upd2(v * 2 + 1, tm + 1, tr, u, x);
    else
      upd2(v * 2, tl, tm, u, x);
    ts[v] = ts[v * 2] + ts[v * 2 + 1];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  p.assign(n, {-1, -1});
  t.assign(4 * n + 5, 0);
  ts.assign(4 * n + 5, 0);
  res.assign(n, 0);
  for (int i = 0; i < n; ++i) {
    cin >> p[i].first;
    p[i].second = i;
  }
  sort(p.begin(), p.end());
  priority_queue<int, vector<int>> l;
  priority_queue<int, vector<int>, greater<int>> g;
  long long inv = 0;
  for (int i = 0; i < n; ++i) {
    inv += qry1(1, 0, n - 1, p[i].second, n - 1);
    res[i] = inv;
    upd2(1, 0, n - 1, p[i].second, p[i].second);
    if (l.size() < g.size()) {
      l.push(p[i].second);
    } else {
      g.push(p[i].second);
    }
    while (l.size() && g.size() && l.top() > g.top()) {
      int x = l.top();
      l.pop();
      l.push(g.top());
      g.pop();
      g.push(x);
    }
    long long pos = 0;
    if (g.size() > l.size()) {
      pos = g.top();
    } else if (g.size() <= l.size()) {
      pos = l.top();
    }
    long long l = i / 2 + 1, r = i - (i / 2) + 1;
    long long ls = l * pos - qry2(1, 0, n - 1, 0, pos) - (l * (l - 1) / 2);
    long long rs = qry2(1, 0, n - 1, pos, n - 1) - r * pos - (r * (r - 1) / 2);
    res[i] = inv + ls + rs;
    upd1(1, 0, n - 1, p[i].second, 1);
  }
  for (auto i : res) {
    cout << i << " ";
  }
  return 0;
}
