#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
const ll MOD = 1e9 + 7;
const ll INF = 1e+18;
const ld EPS = 1e-12L;
const ld PI = acos(-1.L);
inline ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
inline ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) cout << " ";
    }
    if (&v != &vv.back()) cout << "\n";
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&...tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) cout << (f ? " " : "\n");
  print(forward<Tail>(tail)...);
}
struct BIT {
  ll n;
  vector<ll> bit;
  BIT(ll n) : n(n), bit(n + 1, 0) {}
  void add(ll a, ll w) {
    for (ll x = a; x <= n; x += x & -x) bit[x] += w;
  }
  ll sum(ll a) {
    ll ret = 0;
    for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
    return ret;
  }
  ll sum(ll a, ll b) { return sum(b) - sum(a - 1); }
};
template <typename T>
vector<T> argSort(const vector<T> &vec) {
  vector<T> idx(vec.size());
  iota(idx.begin(), idx.end(), 0);
  stable_sort(idx.begin(), idx.end(),
              [&](int l, int r) { return vec[l] < vec[r]; });
  return idx;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll n;
  cin >> n;
  vll a(n);
  for (ll i = 0, i_end = (n); i < i_end; i++) {
    cin >> a[i];
  }
  BIT bt(n);
  vll swaps(n, 0);
  vll dist(n, 0);
  vll arg = argSort(a);
  ll cumsw = 0;
  for (ll i = 0, i_end = (n); i < i_end; i++) {
    cumsw += bt.sum(arg[i] + 2, n);
    swaps[i] = cumsw;
    bt.add(arg[i] + 1, 1);
  }
  ll segmin = INF, segmax = -INF;
  priority_queue<ll> pq;
  priority_queue<ll, vector<ll>, greater<ll>> pq2;
  ll med = arg[0];
  ll cumdist = 0;
  for (ll i = 0, i_end = (n); i < i_end; i++) {
    chmin(segmin, arg[i]);
    chmax(segmax, arg[i]);
    {
      if (i == 0) {
        pq.emplace(arg[i]);
      } else if (i % 2 == 0) {
        if (arg[i] < med) {
          pq.emplace(arg[i]);
        } else {
          pq2.emplace(arg[i]);
          pq.emplace(pq2.top());
          pq2.pop();
        }
      } else {
        if (arg[i] < med) {
          pq.emplace(arg[i]);
          pq2.emplace(pq.top());
          pq.pop();
        } else {
          pq2.emplace(arg[i]);
        }
      }
    }
    ll nm = pq.top();
    if (nm > med) {
      cumdist += arg[i] - nm;
    } else {
      cumdist += abs(arg[i] - med);
    }
    ((void)0);
    med = nm;
    ll j = i + 1;
    dist[i] =
        cumdist - (j % 2 == 0 ? (j / 2) * (j / 2) : (j / 2) * (j / 2 + 1));
  }
  ((void)0);
  ((void)0);
  ((void)0);
  for (ll i = 0, i_end = (n); i < i_end; i++) {
    swaps[i] += dist[i];
  }
  print(swaps);
}
