#include <bits/stdc++.h>
using namespace std;
int P[200005], BIT[200005];
long long F[200005];
priority_queue<int> Q1;
priority_queue<int, vector<int>, greater<int> > Q2;
void update(int i) {
  for (; i <= 200000; i += (i & (-i))) BIT[i]++;
}
int query(int i) {
  int ans = 0;
  for (; i > 0; i -= (i & (-i))) ans += BIT[i];
  return ans;
}
void solve1(int N) {
  long long s1 = 0, s2 = 0;
  for (int i = 1; i <= N; i++) {
    long long k = (i - 1) / 2;
    Q2.push(P[i]), s2 += P[i];
    if ((!Q1.empty() && Q1.top() > Q2.top()) ||
        (int)Q2.size() - Q1.size() > 1) {
      s2 -= Q2.top();
      Q1.push(Q2.top()), s1 += Q2.top();
      Q2.pop();
    }
    if (Q2.size() < Q1.size()) {
      s1 -= Q1.top();
      Q2.push(Q1.top()), s2 += Q1.top();
      Q1.pop();
    }
    if (i % 2)
      F[i] += s2 - Q2.top() - s1 - k * (k + 1);
    else
      F[i] += s2 - s1 - (k + 1) * (k + 1);
  }
}
void solve2(int N) {
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += query(N) - query(P[i]);
    update(P[i]);
    F[i] += ans;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL), cout.tie(NULL);
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    int x;
    cin >> x;
    P[x] = i;
  }
  solve1(N);
  solve2(N);
  for (int i = 1; i <= N; i++) cout << F[i] << " ";
  cout << "\n";
  return 0;
}
