#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;
const int N = 2e5 + 1;
const int B1 = 450;
const int B = 450;
int a[N];
int pos[N];
int n;
int before[N];
int after[N];
long long aftersum[B1];
long long beforesum[B1];
int afterlazy[B1];
int beforelazy[B1];
int mindiff[B1];
bool done[N];
int donebl[B1];
int bit[N];
inline void upd(int ind, int x) {
  while (ind <= n) {
    bit[ind] += x;
    ind += (ind & (-ind));
  }
}
inline int suma(int ind) {
  int res = 0;
  while (ind) {
    res += bit[ind];
    ind -= ind & (-ind);
  }
  return res;
}
inline void resetblock(int which, int pos) {
  aftersum[which] = beforesum[which] = 0;
  mindiff[which] = INF;
  for (int i = which * B; i < min(n, (which + 1) * B); i++) {
    if (done[i]) continue;
    before[i] += beforelazy[which] + (pos < i);
    after[i] += afterlazy[which] + (pos > i);
    if (i == pos) {
      done[pos] = 1;
      donebl[which]++;
      before[i] = after[i] = 0;
    } else {
      mindiff[which] = min(mindiff[which], after[i] - before[i]);
      aftersum[which] += after[i];
      beforesum[which] += before[i];
    }
  }
  beforelazy[which] = afterlazy[which] = 0;
}
inline long long normalreset(int which) {
  long long res = 0;
  aftersum[which] = beforesum[which] = 0;
  mindiff[which] = INF;
  for (int i = which * B; i < min(n, (which + 1) * B); i++) {
    if (done[i]) continue;
    before[i] += beforelazy[which];
    after[i] += afterlazy[which];
    res += min(before[i], after[i]);
    mindiff[which] = min(mindiff[which], after[i] - before[i]);
    aftersum[which] += after[i];
    beforesum[which] += before[i];
  }
  beforelazy[which] = afterlazy[which] = 0;
  return res;
}
inline void normalupdate(int which, int pos) {
  int blsize = min(B, n - which * B);
  if (pos > which * B) {
    afterlazy[which]++;
    aftersum[which] += (blsize - donebl[which]);
    mindiff[which]++;
  } else {
    beforelazy[which]++;
    beforesum[which] += (blsize - donebl[which]);
    mindiff[which]--;
  }
}
int tot;
void solve() {
  cin >> n;
  tot = (n - 1) / B + 1;
  for (int i = 0; i < (int)tot; i++) {
    mindiff[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    pos[x] = i - 1;
  }
  long long firki = 0;
  for (int i = 1; i <= n; i++) {
    firki += (i - 1) - suma(pos[i]);
    upd(pos[i] + 1, 1);
    for (int j = 0; j < (int)tot; j++) {
      if (pos[i] / B == j) {
        resetblock(j, pos[i]);
      } else {
        normalupdate(j, pos[i]);
      }
    }
    bool issaok = 0;
    long long wowsum = 0;
    for (int j = 0; j < (int)tot; j++) {
      if (mindiff[j] < 0 and !issaok) {
        wowsum += normalreset(j);
        issaok = 1;
      } else {
        if (issaok)
          wowsum += aftersum[j];
        else
          wowsum += beforesum[j];
      }
    }
    cout << firki + wowsum << " ";
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
