#include <bits/stdc++.h>
using namespace std;
const int INF = 1061109567;
const long long LINF = 4557430888798830399ll;
const int MOD = 1000000007;
long long qpow(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
struct SegmentTree {
  static const int MAXN = 200000;
  int st[(MAXN << 2) + 5];
  void PushUp(int o) { st[o] = st[(o << 1)] + st[(o << 1 | 1)]; }
  void Build(int o, int l, int r) {
    if (l == r)
      st[o] = 0;
    else {
      int m = l + r >> 1;
      Build((o << 1), l, m);
      Build((o << 1 | 1), m + 1, r);
      PushUp(o);
    }
  }
  void Update(int o, int l, int r, int p, int v) {
    if (l == r) {
      st[o] += v;
      return;
    } else {
      int m = l + r >> 1;
      if (p <= m) Update((o << 1), l, m, p, v);
      if (p >= m + 1) Update((o << 1 | 1), m + 1, r, p, v);
      PushUp(o);
    }
  }
  int Query(int o, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) {
      return st[o];
    } else {
      int m = l + r >> 1;
      int res = 0;
      if (ql <= m) res = res + Query((o << 1), l, m, ql, qr);
      if (qr >= m + 1) res = res + Query((o << 1 | 1), m + 1, r, ql, qr);
      return res;
    }
  }
} st1, st2;
set<int> LL, RR;
int n;
int a[200005], p[200005];
long long ans[200005];
void test_case() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    p[a[i]] = i;
  }
  st1.Build(1, 1, n);
  st2.Build(1, 1, n);
  LL.clear();
  RR.clear();
  st1.Update(1, 1, n, p[1], 1);
  st2.Update(1, 1, n, p[1], 1);
  LL.insert(p[1]);
  int Lmost = p[1], Rmost = p[1];
  long long cnt1 = 0, cnt2 = 0;
  ans[1] = 0;
  for (int i = 2; i <= n; ++i) {
    cnt1 += st1.Query(1, 1, n, p[i], n);
    st1.Update(1, 1, n, p[i], 1);
    if (p[i] < Lmost) {
      for (int j = Lmost - 1; j >= p[i]; --j) st2.Update(1, 1, n, j, 1);
      Lmost = p[i];
    } else if (p[i] > Rmost) {
      for (int j = Rmost + 1; j <= p[i]; ++j) st2.Update(1, 1, n, j, 1);
      Rmost = p[i];
    }
    if (!RR.empty() && p[i] > *RR.begin()) {
      RR.insert(p[i]);
      while (RR.size() > LL.size()) {
        LL.insert(*RR.begin());
        RR.erase(*RR.begin());
      }
    } else {
      LL.insert(p[i]);
      while (LL.size() > RR.size() + 1) {
        RR.insert(*LL.rbegin());
        LL.erase(*LL.rbegin());
      }
    }
    int mid1, mid2;
    mid1 = *LL.rbegin();
    mid2 = (LL.size() == RR.size()) ? (*RR.begin()) : (mid1);
    if (p[i] >= mid2) {
      int ql = mid1 + 1, qr = p[i];
      cnt2 += (ql <= qr ? st2.Query(1, 1, n, ql, qr) : 0) - i / 2;
    } else if (p[i] <= mid1) {
      int ql = p[i] + 1, qr = mid2;
      cnt2 += (ql <= qr ? st2.Query(1, 1, n, ql, qr) : 0) - i / 2;
    }
    ans[i] = cnt1 + cnt2;
  }
  for (int i = 1; i <= n; ++i) printf("%lld%c", ans[i], " \n"[i == n]);
}
int main() {
  int t = 1;
  for (int ti = 1; ti <= t; ++ti) {
    test_case();
  }
}
