#include <bits/stdc++.h>
using namespace std;
int p[200005], ip[200005];
int med;
priority_queue<int> medq;
priority_queue<int, vector<int>, greater<int>> medq2;
int n, h;
long long t[400005], d[200005];
int sz[400005];
void apply(int p, long long v) {
  t[p] += v * sz[p];
  if (p < n) d[p] += v;
}
void push(int p) {
  for (int s = h; s > 0; s--) {
    int p2 = p >> s;
    if (d[p2] != 0) {
      apply(p2 << 1, d[p2]);
      apply(p2 << 1 | 1, d[p2]);
      d[p2] = 0;
    }
  }
}
void build(int p) {
  while (p > 1) {
    p >>= 1;
    t[p] = t[p << 1] + t[p << 1 | 1] + (d[p] * sz[p]);
  }
}
void inc(int l, int r, int value) {
  l += n, r += n;
  int l0 = l, r0 = r;
  for (; l < r; l >>= 1, r >>= 1) {
    if (l & 1) apply(l++, value);
    if (r & 1) apply(--r, value);
  }
  build(l0);
  build(r0 - 1);
}
void modify(int p) {
  t[p += n] = 0;
  sz[p] = 0;
  while (p > 1) {
    p >>= 1;
    sz[p] = sz[p << 1] + sz[p << 1 | 1];
    t[p] = t[p << 1] + t[p << 1 | 1] + (d[p] * sz[p]);
  }
}
long long query(int l, int r, long long k) {
  long long tsz = 0;
  long long ans = 0;
  int lr = r - l;
  push(l + n);
  push(r + n - 1);
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) {
      ans += t[l];
      tsz += sz[l];
      l++;
    }
    if (r & 1) {
      --r;
      ans += t[r];
      tsz += sz[r];
    }
  }
  if (k == -1) return lr - tsz;
  if (k) return (k * tsz) - ans;
  return ans;
}
int getmed(int val) {
  if (med == -1) {
    med = val;
    return med;
  }
  if (val < med) {
    medq.push(val);
    if ((int)medq.size() > (int)medq2.size() + 1) {
      medq2.push(med);
      int val2 = medq.top();
      medq.pop();
      med = val2;
    }
    return med;
  }
  medq2.push(val);
  if ((int)medq2.size() > (int)medq.size() + 1) {
    medq.push(med);
    int val2 = medq2.top();
    medq2.pop();
    med = val2;
  }
  return med;
}
int main() {
  ios::sync_with_stdio(0);
  med = -1;
  cin >> n;
  h = 1;
  while ((n >> h)) h++;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
    ip[p[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    sz[n + i] = 1;
    t[n + i] = 0;
  }
  for (int i = n - 1; i > 0; i--) {
    sz[i] = sz[i << 1] + sz[i << 1 | 1];
    t[i] = 0;
  }
  long long ans = 0;
  long long k = 0;
  long long inv = 0;
  for (int i = 1; i <= n; i++) {
    k++;
    modify(ip[i] - 1);
    inc(ip[i] - 1, n, 1);
    inv += query(ip[i], n, -1);
    med = getmed(ip[i]);
    ans = inv;
    ans += query(0, med - 1, 0);
    ans += query(med - 1, n, k);
    cout << ans << " ";
  }
  return 0;
}
