#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200100;
const int offset = (1 << 18);
struct tournament {
  long long p[offset * 2];
  long long prop[offset * 2];
  long long mult[offset * 2];
  long long killed[offset * 2];
  void init() {
    for (int i = (0); i < int(offset * 2); i++) mult[i] = 1;
  }
  void send_prop(int cvor, long long l) {
    for (int i = (cvor * 2); i < int(cvor * 2 + 2); i++) {
      prop[i] += prop[cvor];
      p[i] += prop[cvor] * (l - killed[i]) * mult[i];
    }
    prop[cvor] = 0;
  }
  void ubij(int x) {
    int t = x;
    update(1, 0, offset - 1, t, t, 0);
    mult[x + offset] = 0;
    p[x + offset] = 0;
    x += offset;
    while (x) {
      killed[x]++;
      x /= 2;
    }
    update(1, 0, offset - 1, t, t, 0);
  }
  void print() {
    for (int i = (1); i < int(offset * 2); i++) {
      cerr << "i _ p[i] _ prop[i] _ mult[i] _ killed[i]"
           << "  " << i << " " << p[i] << " " << prop[i] << " " << mult[i]
           << " " << killed[i] << endl;
    }
  }
  void update(int cvor, int l, int r, int a, int b, long long x) {
    if (l > b || r < a) return;
    if (l >= a && r <= b) {
      p[cvor] += (long long)(r - l + 1 - killed[cvor]) * x * mult[cvor];
      prop[cvor] += x;
      return;
    }
    send_prop(cvor, (r - l + 1) / 2);
    int mid = (l + r) / 2;
    update(cvor * 2, l, mid, a, b, x);
    update(cvor * 2 + 1, mid + 1, r, a, b, x);
    if (mult[cvor])
      p[cvor] = p[cvor * 2] + p[cvor * 2 + 1];
    else
      p[cvor] = 0;
  }
  long long get(int cvor, int l, int r, int a, int b) {
    if (l > r) return 0;
    if (l > b || r < a) return 0;
    if (l >= a && r <= b) return p[cvor] * mult[cvor];
    send_prop(cvor, (r - l + 1) / 2);
    int mid = (l + r) / 2;
    long long X = get(cvor * 2, l, mid, a, b);
    long long Y = get(cvor * 2 + 1, mid + 1, r, a, b);
    return X + Y;
  }
} L, R, inv, akt;
int n, p[MAXN];
int invs[MAXN];
vector<pair<int, int> > v;
int mini = (1 << 30);
int maks = -1;
set<int> s;
int main() {
  L.init();
  R.init();
  inv.init();
  akt.init();
  scanf("%d", &n);
  for (int i = (0); i < int(n); i++) scanf("%d", &p[i]);
  for (int i = (0); i < int(n); i++) v.push_back({p[i], i});
  sort((v).begin(), (v).end());
  for (int i = (0); i < int(n); i++) {
    invs[v[i].first] = inv.get(1, 0, offset - 1, v[i].second, v[i].second);
    inv.update(1, 0, offset - 1, 0, v[i].second, 1);
  }
  long long tmp = 0;
  set<int>::iterator it;
  for (int i = (0); i < int(n); i++) {
    s.insert(v[i].second);
    if (!i)
      it = s.begin();
    else {
      if (i % 2 == 0) {
        if (v[i].second > *it) it++;
      } else {
        if (v[i].second < *it) it--;
      }
    }
    mini = min(mini, v[i].second);
    maks = max(maks, v[i].second);
    tmp += invs[v[i].first];
    L.ubij(v[i].second);
    R.ubij(v[i].second);
    L.update(1, 0, offset - 1, v[i].second, n - 1, 1);
    R.update(1, 0, offset - 1, 0, v[i].second, 1);
    int poc = mini;
    int kraj = maks;
    int lo = *it;
    printf("%lld ", tmp + L.get(1, 0, offset - 1, poc, lo) +
                        R.get(1, 0, offset - 1, lo + 1, kraj));
  }
  puts("");
  return 0;
}
