#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, a[N], place[N], BIT[N];
long long inverse, res[N];
set<int> firstHalf, secondHalf;
long long sumFirst = 0, sumSecond = 0;
long long fenwickGet(int x) {
  long long res = 0;
  for (; x <= n; x += x & -x) res += BIT[x];
  return res;
}
void stable(set<int>& f, set<int>& s) {
  while (f.size() > s.size()) {
    int leftLarge = *f.rbegin();
    f.erase(leftLarge);
    s.insert(leftLarge);
    sumFirst -= leftLarge;
    sumSecond += leftLarge;
  }
  while (f.size() < s.size()) {
    int rightSmall = *s.begin();
    s.erase(rightSmall);
    f.insert(rightSmall);
    sumFirst += rightSmall;
    sumSecond -= rightSmall;
  }
}
void fenwickUpdate(int x) {
  for (; x; x -= x & -x) BIT[x] += 1;
}
long long sol(int cur) {
  inverse += fenwickGet(cur);
  fenwickUpdate(cur);
  if (firstHalf.size() > 0) {
    if (cur > *firstHalf.rbegin()) {
      secondHalf.insert(cur);
      sumSecond += cur;
    } else {
      firstHalf.insert(cur);
      sumFirst += cur;
    }
  } else {
    firstHalf.insert(cur);
    sumFirst += cur;
  }
  stable(firstHalf, secondHalf);
  long long middle = *firstHalf.rbegin();
  long long n = firstHalf.size(), m = secondHalf.size();
  return inverse + middle * n - sumFirst - n * (n - 1) / 2 + sumSecond -
         middle * m - m * (m + 1) / 2;
}
void solve() {
  inverse = 0;
  for (int i = 1; i <= n; ++i) {
    char c = (i == n ? '\n' : ' ');
    cout << sol(place[i]) << c;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    place[a[i]] = i;
  }
  solve();
  return 0;
}
