#include <bits/stdc++.h>
template <class T>
inline void read(T &x) {
  x = 0;
  register char c = getchar();
  register bool f = 0;
  while (!isdigit(c)) f ^= c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  if (f) x = -x;
}
template <class T>
inline void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
template <class T>
inline void print(T x, char c) {
  print(x), putchar(c);
}
template <class T>
inline void print(T x, long long l, long long r) {
  for (long long i = l; i <= r; i++) print(x[i], " \n"[i == r]);
}
const long long N = 1e6 + 10;
long long n, a[N];
long long ans[N], s[N], f[N], lst, sum;
inline long long calc(long long l, long long r) {
  return l > r ? 0 : (long long)(l + r) * (r - l + 1) / 2;
}
inline void add(long long k, long long x, long long *s) {
  if (k == 0) {
    s[0] += x;
    return;
  }
  for (; k <= n; k += k & -k) s[k] += x;
}
inline long long ask(long long k, long long *s) {
  long long r = s[0];
  for (; k; k -= k & -k) r += s[k];
  return r;
}
inline long long search(long long ss) {
  long long l = 1, r = n, res = -1;
  while (l <= r) {
    long long mid = (l + r) >> 1, t = ask(mid, s);
    t >= ss - t ? (r = mid - 1, res = mid) : (l = mid + 1);
  }
  return res;
}
signed main() {
  read(n);
  for (long long i = 1, x; i <= n; i++) read(x), a[x] = i;
  for (long long i = 1, k; i <= n; i++) {
    add(a[i], 1, s), add(a[i], a[i], f);
    k = search(i);
    sum -= ask(a[i] - 1, s);
    lst += i - ask(a[i], s);
    ans[i] += lst;
    long long ll = (i & 1) ? i >> 1 : (i >> 1) - 1;
    long long rr = i - ll - 1;
    ans[i] += calc(k - ll, k - 1) - ask(k - 1, f);
    ans[i] += ask(n, f) - ask(k, f) - calc(k + 1, k + rr);
    sum += (n - a[i]) - (i - ask(a[i], s));
  }
  for (long long i = 1; i <= n; i++) print(ans[i], " \n"[i == n]);
}
