#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = false;
  while (!isdigit(c)) {
    if (c == '-') flag = true;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  if (flag) x = -x;
}
int n;
long long sum, v2;
int pos[400010];
long long s[400010], c[400010];
void update(int x) {
  int v = x;
  while (x <= n) s[x] += v, c[x]++, x += (x & (-x));
}
long long ask1(int x) {
  long long v = 0;
  while (x) v += c[x], x -= (x & (-x));
  return v;
}
long long ask2(int x) {
  long long v = 0;
  while (x) v += s[x], x -= (x & (-x));
  return v;
}
int find(int k) {
  int x = 0;
  for (int j = 20; j >= 0; --j)
    if ((x | (1 << j)) <= n && c[x | (1 << j)] <= k) x |= 1 << j, k -= c[x];
  return x;
}
int main() {
  read(n);
  for (int i = 1, a; i <= n; ++i) read(a), pos[a] = i;
  for (int i = 1; i <= n; ++i) {
    update(pos[i]), sum += i - ask1(pos[i]);
    long long p = find(i / 2) + 1, c1 = ask1(p - 1), c2 = ask1(n) - ask1(p),
              s1 = ask2(p - 1), s2 = ask2(n) - ask2(p);
    printf("%lld ", sum + c1 * p - s1 + s2 - c2 * p - (c1 + 1) * c1 / 2 -
                        (c2 + 1) * c2 / 2);
  }
  return 0;
}
