#include <bits/stdc++.h>
using namespace std;
const int MX = 2e5 + 5;
int n;
int Bit[MX];
int Idx[MX];
int Inv[MX];
int Pos[MX];
vector<int> A;
void Add_Bit(int x, int val) {
  for (; x <= n + 1; x += x & -x) Bit[x] += val;
}
void Add_Idx(int x, int val) {
  for (; x <= n + 1; x += x & -x) Idx[x] += val;
}
long long Get_Bit(int x) {
  long long res = 0;
  for (; x > 0; x -= x & -x) res += Bit[x];
  return res;
}
long long Get_Idx(int x) {
  long long res = 0;
  for (; x > 0; x -= x & -x) res += Idx[x];
  return res;
}
void prep() {
  for (int i = 0; i <= n; ++i) {
    Bit[i] = 0;
    Idx[i] = 0;
    Pos[i] = 0;
  }
}
int main() {
  scanf("%d", &n);
  prep();
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    A.push_back(x);
    Pos[x] = i + 1;
  }
  for (int i = n - 1; i >= 0; --i) {
    Inv[A[i]] = Get_Bit(A[i]);
    Add_Bit(A[i], 1);
  }
  for (int i = 1; i <= n; ++i) {
    Bit[i] = 0;
  }
  Add_Bit(Pos[1], 1);
  Add_Idx(Pos[1], Pos[1]);
  long long ans = Inv[1];
  int L = Pos[1];
  int R = Pos[1];
  cout << Inv[1] << " ";
  for (int i = 2; i <= n; ++i) {
    ans += Inv[i];
    L = min(L, Pos[i]);
    R = max(R, Pos[i]);
    Add_Bit(Pos[i], 1);
    Add_Idx(Pos[i], Pos[i]);
    int m = (L + R) >> 1;
    int Ri = Get_Bit(n) - Get_Bit(m);
    int Le = Get_Bit(m - 1);
    ans += Get_Idx(n) - Get_Idx(m) - (Ri - 1) * m;
    ans += Le * m - Get_Idx(m);
    ans -= Ri * (Ri + 1) / 2;
    ans -= Le * (Le + 1) / 2;
    cout << ans << " ";
  }
  puts("");
}
