#include <bits/stdc++.h>
using namespace std;
const int maxn = 200007;
const int apsz = 26;
inline int lowbit(int x) { return x & (-x); }
struct BIT {
 public:
  vector<long long> a;
  int n;
  BIT(int nn = maxn) {
    n = nn;
    a = vector<long long>(n + 1, 0);
  }
  long long Query(int L, int R) {
    long long ansl, ansr;
    ansl = ansr = 0;
    if (L > R) return 0;
    for (int i = L - 1; i; i -= lowbit(i)) ansl += a[i];
    for (int i = R; i; i -= lowbit(i)) ansr += a[i];
    return ansr - ansl;
  }
  void Add(int pos, int v) {
    for (int i = pos; i <= n; i += lowbit(i)) a[i] += v;
  }
};
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> pos(n + 1);
  BIT tr1(n);
  BIT tr2(n);
  for (int i = (1); i <= (n); ++i) {
    int x;
    cin >> x;
    pos[x] = i;
  }
  long long inv = 0;
  for (int i = (1); i <= (n); ++i) {
    long long ans = 0;
    inv += i - 1 - tr1.Query(1, pos[i]);
    tr1.Add(pos[i], 1), tr2.Add(pos[i], pos[i]);
    if (i == 1) {
      cout << 0;
      continue;
    }
    long long L, R;
    L = 1, R = n;
    while (L < R) {
      long long mid = L + (R - L + 1) / 2;
      if (tr1.Query(1, mid) * 2 > i)
        R = mid - 1;
      else
        L = mid;
    }
    long long MID = L;
    long long cntL = tr1.Query(1, MID);
    long long cntR = i - cntL;
    long long sumL = tr2.Query(1, MID);
    long long sumR = tr2.Query(MID + 1, n);
    ans = MID * cntL - (0 + cntL - 1) * cntL / 2 - sumL;
    ans += sumR - (MID + 1) * cntR - (0 + cntR - 1) * cntR / 2;
    cout << " " << ans + inv;
  }
  cout << endl;
  return 0;
}
