#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct BIT {
  int n;
  vector<T> dat;
  BIT(int n = 0) { initialize(n); }
  void initialize(int nin) {
    n = nin;
    dat.resize(n, 0);
  }
  T sum(int i) {
    T s = 0;
    while (i >= 0) {
      s += dat[i];
      i = (i & (i + 1)) - 1;
    }
    return s;
  }
  T sum_between(int i, int j) { return sum(j) - sum(i - 1); }
  void plus(int i, T x) {
    while (i < n) {
      dat[i] += x;
      i |= i + 1;
    }
  }
  int lower_bound(T x) {
    if (x < 0) return -1;
    int ret = -1;
    int k = 1;
    while (2 * k <= n) k <<= 1;
    for (; k > 0; k >>= 1) {
      if (ret + k < n && dat[ret + k] < x) {
        x -= dat[ret + k];
        ret += k;
      }
    }
    return ret + 1;
  }
};
int main() {
  int N;
  cin >> N;
  vector<int> P(N), pos(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
    P[i]--;
    pos[P[i]] = i;
  }
  BIT<int64_t> bit_inv(N), bit_pos(N);
  vector<int64_t> ans1(N), ans2(N);
  for (int i = 0; i < N; i++) {
    ans1[i] = bit_inv.sum_between(pos[i], N - 1);
    bit_inv.plus(pos[i], 1);
    if (i > 0) ans1[i] += ans1[i - 1];
    bit_pos.plus(pos[i], pos[i]);
    int num = i + 1;
    int64_t c = bit_inv.lower_bound((num + 1) / 2);
    int l = (num + 1) / 2;
    int r = num - l;
    ans2[i] += (2 * c - l + 1) * l / 2 - bit_pos.sum_between(0, c);
    ans2[i] += bit_pos.sum_between(c + 1, N - 1) - (2 * c + 1 + r) * r / 2;
  }
  for (int i = 0; i < N; i++) cout << (ans1[i] + ans2[i]) << " \n"[i == N - 1];
  return 0;
}
