#include <bits/stdc++.h>
using namespace std;
ifstream in;
ofstream out;
const long long kk = 1000;
const long long ml = kk * kk;
const long long mod = ml * kk + 7;
const long long inf = ml * ml * ml + 7;
long long n, i, j;
vector<long long> m, pl;
bool viv = false;
struct Tree {
  int s = 1;
  int n = 0;
  int my_null = 0;
  vector<pair<long long, long long> > t;
  vector<pair<long long, long long> > seg;
  inline long long res(long long v1, long long v2) { return v1 + v2; }
  void cnt_seg() {
    seg.resize(2 * s);
    seg[1] = {0, s};
    for (int i = 1; i < s; i++) {
      int tm = seg[i].first + seg[i].second >> 1;
      seg[2 * i] = {seg[i].first, tm};
      seg[2 * i + 1] = {tm, seg[i].second};
    }
  }
  void build(long long sz) {
    n = sz;
    while (s < n) s <<= 1;
    t.resize(2 * s, {my_null, my_null});
    cnt_seg();
  }
  void build(vector<long long> v) {
    n = v.size();
    while (s < n) s <<= 1;
    t.resize(2 * s, {my_null, my_null});
    for (int i = 0; i < n; i++) t[s + i] = {v[i], my_null};
    for (int i = s - 1; i > 0; i--) upd(i);
    cnt_seg();
  }
  void upd(int v) {
    if (v >= s) return;
    t[v].first = res(t[2 * v].first, t[2 * v + 1].first);
  }
  void push(int v) {
    if (v >= s) return;
    long long p = t[v].second;
    if (p == my_null) return;
    t[v].second = my_null;
    t[2 * v].second = p;
    t[2 * v + 1].second = p;
    t[2 * v].first = res(t[2 * v].first, p);
    t[2 * v + 1].first = res(t[2 * v + 1].first, p);
  }
  void tree_add(long long v, long long val) {
    t[v].first += val * (seg[v].second - seg[v].first);
    t[v].second = res(t[v].second, val);
  }
  long long val(int l, int r, int v, int tl, int tr) {
    if (r <= tl || tr <= l) return my_null;
    push(v);
    if (l <= tl && tr <= r) return t[v].first;
    int tm = tl + tr >> 1;
    long long v1 = val(l, r, 2 * v, tl, tm);
    long long v2 = val(l, r, 2 * v + 1, tm, tr);
    upd(v);
    return res(v1, v2);
  }
  void add(int l, int r, int v, int tl, int tr, long long val) {
    if (r < tl || tr < l) return;
    push(v);
    if (l <= tl && tr <= r) {
      tree_add(v, val);
      return;
    }
    int tm = tl + tr >> 1;
    add(l, r, 2 * v, tl, tm, val);
    add(l, r, 2 * v + 1, tm, tr, val);
  }
  long long val(int l, int r) { return val(l, r + 1, 1, 0, s); }
  void add(int v, long long val) {
    v += s;
    while (v) t[v].first = res(t[v].first, val), v >>= 1;
  }
  void add(int l, int r, long long t) { add(l, r + 1, 1, 0, s, t); }
  void show() {
    for (long long i = 1; i < 2 * s; i++) {
      cout << '\t' << '{' << t[i].first << ' ' << t[i].second << "} ";
      if ((i & (i + 1)) == 0) cout << endl;
    }
  }
};
long long summ(long long l, long long r) {
  long long res = ((r - l + 1) * (l + r)) / 2;
  if (viv) cout << "Sum on " << l << ' ' << r << " is " << res << endl;
  return res;
}
void solve() {
  cin >> n;
  m.resize(n);
  for (auto &i : m) cin >> i, i--;
  pl.resize(n);
  for (long long i = 0; i < n; i++) {
    pl[m[i]] = i;
  }
  Tree t, sm;
  t.build(n);
  sm.build(n);
  long long ans = 0;
  set<long long> p;
  long long mid = 0;
  for (long long i = 0; i < n; i++) {
    long long tran = t.val(pl[i], n - 1);
    ans += tran;
    long long lans = ans;
    p.insert(pl[i]);
    if (p.size() == 1) mid = pl[i];
    if (i & 1) {
      if (pl[i] < mid) {
        auto z = p.find(mid);
        z--;
        mid = *z;
      }
    } else {
      if (pl[i] > mid) {
        auto z = p.find(mid);
        z++;
        mid = *z;
      }
    }
    sm.add(pl[i], pl[i]);
    long long aft = (i + 1) / 2;
    long long bef = i - aft;
    long long hb = sm.val(0, mid - 1);
    long long wb = summ(mid - bef, mid - 1);
    long long ha = sm.val(mid + 1, n - 1);
    long long wa = summ(mid + 1, mid + aft);
    if (viv) {
      cout << "My mid is " << mid << endl;
      cout << hb << ' ' << wb << ' ' << ha << ' ' << wa << endl;
      cout << aft << ' ' << bef << endl;
      cout << i << ": " << (i + 1) / 2 << ' ' << i - (i + 1) / 2 << endl;
    }
    lans += wb - hb;
    lans += ha - wa;
    if (viv) cout << "         Ans = ";
    cout << lans << ' ';
    if (viv) cout << endl;
    t.add(pl[i], 1);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
