#include <bits/stdc++.h>
using namespace std;
struct segment_tree {
  vector<long long> st;
  vector<long long> lz;
  segment_tree(int n) {
    st = vector<long long>(4 * n);
    lz = vector<long long>(4 * n);
  }
  void push(int p, int l, int r, int b, int m, int e) {
    if (lz[p]) {
      lz[l] += lz[p];
      st[l] += lz[p] * (m - b);
      lz[r] += lz[p];
      st[r] += lz[p] * (e - m);
      lz[p] = 0;
    }
  }
  void update(int p, int b, int e, int x, int y, long long v) {
    if (y <= x) return;
    if (x <= b && e <= y) {
      lz[p] += v;
      st[p] += v * (e - b);
    } else {
      int m = (b + e) >> 1, l = p << 1, r = l | 1;
      push(p, l, r, b, m, e);
      if (x < m) update(l, b, m, x, y, v);
      if (m < y) update(r, m, e, x, y, v);
      st[p] = st[l] + st[r];
    }
  }
  long long query(int p, int b, int e, int x, int y) {
    if (y <= x) return 0;
    if (x <= b && e <= y) {
      return st[p];
    } else {
      int m = (b + e) >> 1, l = p << 1, r = l | 1;
      push(p, l, r, b, m, e);
      long long ans = 0;
      if (x < m) ans += query(l, b, m, x, y);
      if (m < y) ans += query(r, m, e, x, y);
      return ans;
    }
  }
};
class CKIntegers {
 public:
  void solve(std::istream &in, std::ostream &out) {
    int n;
    in >> n;
    vector<int> inv(n);
    segment_tree le(n), ri(n);
    for (int i = 0; i < n; ++i) {
      int u;
      in >> u;
      u--;
      inv[u] = i;
    }
    long long inversions = 0;
    for (int i = 0; i < n; ++i) {
      int p = inv[i];
      inversions += ri.query(1, 0, n, p, p + 1);
      le.update(1, 0, n, p + 1, n, +1);
      ri.update(1, 0, n, 0, p, +1);
      int tot = i + 1;
      int target = (tot + 1) / 2;
      int lo = 0, hi = n;
      while (lo + 1 < hi) {
        int mid = (lo + hi) / 2;
        if (le.query(1, 0, n, mid, mid + 1) >= target) {
          hi = mid;
        } else {
          lo = mid;
        }
      }
      long long tle = target;
      long long tri = tot - tle;
      long long LE = le.query(1, 0, n, 0, hi) - tle * (tle - 1) / 2;
      long long RI = ri.query(1, 0, n, hi, n) - tri * (tri - 1) / 2;
      out << inversions + LE + RI << " ";
    }
    out << endl;
  }
};
int main() {
  CKIntegers solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}
