#include <bits/stdc++.h>
using namespace std;
struct BIT {
  std::vector<long long> T;
  BIT(long long n) { T = std::vector<long long>(n + 3, 0); }
  long long get(long long i) const {
    i++;
    long long s = 0;
    while (i > 0) {
      s += T[i];
      i -= i & -i;
    }
    return s;
  }
  void add(long long i, long long a) {
    i++;
    while (i < T.size()) {
      T[i] += a;
      i += i & -i;
    }
  }
  long long range(long long a, long long b) const {
    return get(b) - get(a - 1);
  }
};
template <typename T>
void read_to_vector(size_t N, std::vector<T> &v) {
  for (size_t i = 0; i < N; i++) {
    T tmp;
    std::cin >> tmp;
    v.push_back(tmp);
  }
}
template <typename T>
void print_vector(const std::vector<T> &v) {
  for (auto it = v.begin(); it < v.end(); it++) {
    if (it != v.begin()) std::cout << " ";
    std::cout << (*it);
  }
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> p;
  read_to_vector(n, p);
  vector<long long> pinv(n + 1, 0);
  for (int i = 0; i < n; i++) {
    pinv[p[i]] = i;
  }
  BIT bit(n);
  BIT pos(n);
  vector<long long> n_after(n + 1, 0);
  long long nint = 0;
  vector<long long> res(n, 0);
  for (int k = 1; k <= n; k++) {
    n_after[k] = k - 1 - bit.get(pinv[k]);
    nint += n_after[k];
    bit.add(pinv[k], 1);
    pos.add(pinv[k], pinv[k]);
    long long val = (k + 1) / 2;
    int a = 0, b = n - 1;
    while (b > a) {
      int c = (a + b) / 2;
      long long v = bit.get(c);
      if (v < val) {
        a = c + 1;
      } else {
        b = c;
      }
    }
    if (k == 1) {
      val = 1;
      a = pinv[1];
    }
    long long next_bef = (val - 1) * a - pos.get(a - 1) - (val * (val - 1) / 2);
    long long next_aft =
        pos.range(a + 1, n) - (k - val) * a - ((k - val) * (k - val + 1) / 2);
    res[k - 1] = nint + next_bef + next_aft;
  }
  print_vector(res);
  cout << endl;
}
void pre_compute() {}
int main() {
  std::cout << std::setprecision(15);
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  pre_compute();
  solve();
  return 0;
}
