#include <bits/stdc++.h>
using namespace std;
class BinTree : vector<long long> {
 public:
  explicit BinTree(long long k = 0) { assign(k + 1, 0); }
  long long lowbit(long long k) { return k & -k; }
  long long sum(long long k) {
    return k > 0 ? sum(k - lowbit(k)) + (*this)[k] : 0;
  }
  long long last() { return size() - 1; }
  void add(long long k, long long w) {
    if (k > last()) return;
    (*this)[k] += w;
    add(k + lowbit(k), w);
  }
};
long long n;
vector<long long> ps;
vector<long long> mp;
vector<long long> ress;
BinTree bt0, bt1;
void solve() {
  bt0 = BinTree(n);
  bt1 = BinTree(n);
  ress = vector<long long>(n + 1, 0);
  long long s = 0;
  for (long long p = 1; p <= n; p++) {
    long long res = ress[p - 1];
    long long pi = mp[p];
    s += pi;
    long long mi = s / p;
    bt0.add(pi, 1);
    bt1.add(pi, pi);
    if (ps[mi] > p) {
      long long cn = bt0.sum(mi - 1);
      long long sn = bt1.sum(mi - 1);
      res += cn * mi - sn - (cn - 1) * cn / 2;
      cn = bt0.sum(n) - bt0.sum(mi);
      sn = bt1.sum(n) - bt1.sum(mi);
      res += sn - cn * mi - cn - (cn - 1) * cn / 2;
      res += bt0.sum(n) - bt0.sum(pi);
    } else {
      long long cn = bt0.sum(mi - 1);
      long long sn = bt1.sum(mi - 1);
      res += cn * mi - sn - cn - (cn - 1) * cn / 2;
      cn = bt0.sum(n) - bt0.sum(mi);
      sn = bt1.sum(n) - bt1.sum(mi);
      res += sn - cn * mi - cn - (cn - 1) * cn / 2;
      res += bt0.sum(n) - bt0.sum(pi);
    }
    ress[p] = res;
    cout << res << " ";
  }
  cout << endl;
}
int main() {
  scanf("%d", &n);
  ps = vector<long long>(n + 1, 0);
  mp = vector<long long>(n + 1, 0);
  for (long long i = 1; i <= n; i++) {
    scanf("%d", &ps[i]);
    mp[ps[i]] = i;
  }
  solve();
  return 0;
}
