#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int ret = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
  return w * ret;
}
int n, tot, root;
int a[200010];
int pos[200010];
struct node {
  int l, r;
  int dat, val;
  long long num;
  int size;
} f[200010];
void update(int p) {
  f[p].size = f[f[p].l].size + f[f[p].r].size + 1;
  f[p].num = f[f[p].l].num + f[f[p].r].num + (long long)f[p].val;
}
int New(int val) {
  f[++tot].val = val;
  f[tot].dat = rand();
  f[tot].size = 1;
  f[tot].num = (long long)val;
  return tot;
}
void split(int p, int val, int &x, int &y) {
  if (p == 0) {
    x = 0, y = 0;
    return;
  }
  if (f[p].val <= val) {
    x = p;
    split(f[p].r, val, f[p].r, y);
  } else {
    y = p;
    split(f[p].l, val, x, f[p].l);
  }
  update(p);
}
int merge(int a, int b) {
  if (!a || !b) return a + b;
  if (f[a].dat < f[b].dat) {
    f[a].r = merge(f[a].r, b);
    update(a);
    return a;
  } else {
    f[b].l = merge(a, f[b].l);
    update(b);
    return b;
  }
}
void insert(int val) {
  int x, y;
  split(root, val, x, y);
  root = merge(merge(x, New(val)), y);
}
int getVal(int p, int rank) {
  while (p) {
    if (f[f[p].l].size >= rank)
      p = f[p].l;
    else if (f[f[p].l].size + 1 == rank)
      return f[p].val;
    else
      rank -= f[f[p].l].size + 1, p = f[p].r;
  }
}
long long cal(long long x) {
  if (x == 1) return 0;
  int mid = (x + 1) / 2;
  long long place = (long long)getVal(root, mid);
  if (x % 2 == 0) {
    long long ret = 0;
    int u, v, w;
    split(root, place - 1, u, v);
    split(v, place, v, w);
    ret += (place - (x - 1) / 2 + place - 1) * ((x - 1) / 2) / 2;
    ret -= f[u].num;
    ret += f[w].num;
    ret -= (place + 1 + place + x / 2) * (x / 2) / 2;
    root = merge(merge(u, v), w);
    return ret;
  } else {
    long long ret = 0;
    int u, v, w;
    split(root, place - 1, u, v);
    split(v, place, v, w);
    ret += (place - (x / 2) + place - 1) * (x / 2) / 2;
    ret -= f[u].num;
    ret += f[w].num;
    ret -= (place + 1 + place + (x / 2)) * (x / 2) / 2;
    root = merge(merge(u, v), w);
    return ret;
  }
}
int d[200010];
inline int lowbit(int x) { return x & (-x); }
void modify(int x, int val) {
  for (; x <= n; x += lowbit(x)) d[x] += val;
}
int query(int x) {
  int ret = 0;
  for (; x; x -= lowbit(x)) ret += d[x];
  return ret;
}
long long ans = 0;
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    pos[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    insert(pos[i]);
    ans += (long long)query(pos[i]);
    modify(1, 1);
    modify(pos[i], -1);
    printf("%lld ", ans + cal((long long)i));
  }
  printf("\n");
}
