#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 555;
long long saveori[maxn];
long long savepos[maxn];
long long tree[maxn << 2];
void update(long long nowid, long long l, long long r, long long pos,
            long long v) {
  if (l == r) {
    tree[nowid] = v;
    return;
  }
  if (pos <= ((l + r) >> 1)) update((nowid << 1), l, ((l + r) >> 1), pos, v);
  if (((l + r) >> 1) < pos)
    update(((nowid << 1) | 1), ((l + r) >> 1) + 1, r, pos, v);
  tree[nowid] = tree[(nowid << 1)] + tree[((nowid << 1) | 1)];
}
long long query(long long nowid, long long l, long long r, long long ql,
                long long qr) {
  if (ql <= l && r <= qr) return tree[nowid];
  long long res = 0;
  if (ql <= ((l + r) >> 1))
    res += query((nowid << 1), l, ((l + r) >> 1), ql, qr);
  if (((l + r) >> 1) < qr)
    res += query(((nowid << 1) | 1), ((l + r) >> 1) + 1, r, ql, qr);
  return res;
}
long long tree1[maxn << 2];
void update1(long long nowid, long long l, long long r, long long pos,
             long long v) {
  if (l == r) {
    tree1[nowid] = v;
    return;
  }
  if (pos <= ((l + r) >> 1)) update1((nowid << 1), l, ((l + r) >> 1), pos, v);
  if (((l + r) >> 1) < pos)
    update1(((nowid << 1) | 1), ((l + r) >> 1) + 1, r, pos, v);
  tree1[nowid] = tree1[(nowid << 1)] + tree1[((nowid << 1) | 1)];
}
long long query1(long long nowid, long long l, long long r, long long ql,
                 long long qr) {
  if (ql <= l && r <= qr) return tree1[nowid];
  long long res = 0;
  if (ql <= ((l + r) >> 1))
    res += query1((nowid << 1), l, ((l + r) >> 1), ql, qr);
  if (((l + r) >> 1) < qr)
    res += query1(((nowid << 1) | 1), ((l + r) >> 1) + 1, r, ql, qr);
  return res;
}
long long n;
long long getpos(long long k) {
  long long cnt = (k + 1) / 2;
  long long l = 1, r = n;
  long long pos = 0;
  while (l <= r) {
    long long now = query(1, 1, n, 1, ((l + r) >> 1));
    now = ((l + r) >> 1) - now;
    if (cnt <= now) {
      pos = ((l + r) >> 1);
      r = ((l + r) >> 1) - 1;
    } else
      l = ((l + r) >> 1) + 1;
  }
  return pos;
}
inline long long cal1(long long a1, long long n) { return n * (n - 1) / 2; }
void solve() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &saveori[i]);
    savepos[saveori[i]] = i;
  }
  vector<long long> ans;
  ans.push_back(0);
  long long l = savepos[1];
  long long r = savepos[1];
  for (long long i = 2; i <= n; i++) {
    update(1, 1, n, savepos[i], 1);
    update1(1, 1, n, savepos[i], savepos[i]);
  }
  long long last = 0;
  for (long long i = 2; i <= n; i++) {
    update(1, 1, n, savepos[i], 0);
    update1(1, 1, n, savepos[i], 0);
    l = min(l, savepos[i]);
    r = max(r, savepos[i]);
    long long pos = getpos(i);
    long long cnt = query(1, 1, n, l, pos);
    long long sum = query1(1, 1, n, l, pos) - cnt * l - cal1(0, cnt);
    cnt = query(1, 1, n, pos + 1, r);
    sum += (cnt * n - query1(1, 1, n, pos, r)) - cal1(0, cnt) - (n - r) * cnt;
    last += i - (savepos[i] - query(1, 1, n, 1, savepos[i]));
    ans.push_back(last + sum);
  }
  for (long long aa : ans) printf("%lld\n", aa);
}
signed main() { solve(); }
