#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int n;
int a[MAXN], b[MAXN];
long long ans[MAXN], perm[MAXN];
struct SegTree {
  int left(int x) { return 2 * x; }
  int right(int x) { return 2 * x + 1; }
  bool out(int l, int r, int i, int j) { return (l > j || r < i); }
  bool in(int l, int r, int i, int j) { return (l >= i && r <= j); }
  int n;
  vector<long long> st;
  vector<long long> lazy;
  SegTree() {}
  SegTree(int _n) {
    n = _n;
    st.assign(4 * (n + 5), 0);
    lazy.assign(4 * (n + 5), 0);
  }
  void propagate(int p, int l, int r) {
    if (lazy[p] != 0) {
      st[p] += lazy[p] * (r - l + 1);
      if (l < r) {
        lazy[left(p)] += lazy[p];
        lazy[right(p)] += lazy[p];
      }
    }
    lazy[p] = 0;
  }
  void upd(int p, int l, int r, int i, int j, int val) {
    propagate(p, l, r);
    if (out(l, r, i, j)) return;
    if (in(l, r, i, j)) {
      lazy[p] += val;
      propagate(p, l, r);
      return;
    }
    int mid = (l + r) / 2;
    upd(left(p), l, mid, i, j, val);
    upd(right(p), mid + 1, r, i, j, val);
    st[p] = st[left(p)] + st[right(p)];
  }
  long long query(int p, int l, int r, int i, int j) {
    propagate(p, l, r);
    if (out(l, r, i, j)) return 0LL;
    if (in(l, r, i, j)) return st[p];
    int mid = (l + r) / 2;
    return query(left(p), l, mid, i, j) + query(right(p), mid + 1, r, i, j);
  }
  void upd(int i, int j, int val) { upd(1, 1, n, i, j, val); }
  long long query(int i, int j) { return query(1, 1, n, i, j); }
};
struct BIT {
  int n;
  vector<int> ft;
  BIT() {}
  BIT(int _n) {
    n = _n;
    ft.assign(n + 5, 0);
  }
  int lsone(int x) { return (x & (-x)); }
  void upd(int k, int v) {
    for (; k <= n; k += lsone(k)) ft[k] += v;
  }
  int query(int k) {
    int ans = 0;
    for (; k > 0; k -= lsone(k)) ans += ft[k];
    return ans;
  }
  int query(int a, int b) { return query(b) - query(a - 1); }
};
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    b[a[i]] = i;
  }
  SegTree slideLeft, slideRight;
  BIT flag = BIT(n + 1);
  slideLeft = SegTree(n + 1);
  slideRight = SegTree(n + 1);
  for (int i = 1; i <= n; ++i) {
    slideLeft.upd(b[i], n, 1);
    slideRight.upd(1, b[i], 1);
    flag.upd(b[i], 1);
    int l = 1, r = n;
    while (l < r) {
      int mid = (l + r) / 2;
      if (flag.query(1, mid) < flag.query(mid + 1, n))
        l = mid + 1;
      else
        r = mid;
    }
    int numLeft = flag.query(1, l), numRight = flag.query(l + 1, n);
    ans[i] = slideLeft.query(1, l) + slideRight.query(l + 1, n);
    ans[i] -= 1LL * numLeft * (numLeft + 1) / 2;
    ans[i] -= 1LL * numRight * (numRight + 1) / 2;
    perm[i] = perm[i - 1];
    perm[i] += flag.query(b[i] + 1, n);
    ans[i] += perm[i];
  }
  for (int i = 1; i <= n; ++i) {
    if (i > 1) printf(" ");
    printf("%lld", ans[i]);
  }
  printf("\n");
}
