#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
class FenwickTree {
 public:
  void update(int i) {
    for (; i < MAXN; i += i & -i) BIT[i]++;
  }
  int query(int i) {
    int ans = 0;
    for (; i > 0; i -= i & -i) ans += BIT[i];
    return ans;
  }
  FenwickTree() { memset(BIT, 0, sizeof(BIT)); }

 private:
  int BIT[MAXN];
};
int n;
int v[MAXN];
int inv[MAXN];
long long int sumLeft;
long long int sumRight;
set<int> valuesLeft;
set<int> valuesRight;
set<int>::iterator it;
FenwickTree BIT;
void add(int k) {
  if (valuesLeft.size() == valuesRight.size()) {
    sumLeft += k;
    valuesLeft.insert(k);
    it = valuesLeft.end();
    it--;
    sumLeft -= *it;
    sumRight += *it;
    valuesRight.insert(*it);
    valuesLeft.erase(it);
  } else {
    sumRight += k;
    valuesRight.insert(k);
    it = valuesRight.begin();
    sumRight -= *it;
    sumLeft += *it;
    valuesLeft.insert(*it);
    valuesRight.erase(it);
  }
}
long long int qtdSwaps() {
  long long int szLeft = valuesLeft.size();
  long long int szRight = valuesRight.size();
  int median = *valuesRight.begin();
  long long int sum = sumRight - sumLeft;
  sum += szLeft * median;
  sum -= szRight * median;
  sum -= (szLeft * (szLeft + 1)) / 2;
  sum -= (szRight * (szRight - 1)) / 2;
  return sum;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &v[i]);
    inv[v[i]] = i;
  }
  long long int qtdInversions = 0;
  for (int i = 1; i <= n; i++) {
    qtdInversions += (i - 1) - BIT.query(inv[i]);
    BIT.update(inv[i]);
    add(inv[i]);
    printf("%lld ", qtdInversions + qtdSwaps());
  }
}
