#include <bits/stdc++.h>
using namespace std;
template <typename T>
void __read(T &a) {
  cin >> a;
}
template <typename T, typename... Args>
void __read(T &a, Args &...args) {
  cin >> a;
  __read(args...);
}
constexpr long long M7 = 1000000007ll;
constexpr long long M9 = 1000000009ll;
constexpr long long MFFT = 998244353ll;
template <class T>
void outv(T &a) {
  for (auto &x : a) cout << x << ' ';
}
static mt19937 rnd(static_cast<unsigned>(
    chrono::steady_clock::now().time_since_epoch().count()));
template <class T>
static auto __super_speed__ = (ios_base::sync_with_stdio(0), cin.tie(0));
void inc(int i, vector<int> &ft) {
  for (; i < ft.size(); i |= i + 1) {
    ft[i]++;
  }
}
int sum(int i, vector<int> &ft) {
  int res = 0;
  for (; i >= 0; i = (i & (i + 1)) - 1) {
    res += ft[i];
  }
  return res;
}
int sum(int l, int r, vector<int> &ft) { return sum(r, ft) - sum(l - 1, ft); }
int32_t main() {
  int n;
  __read(n);
  vector<int> a(n), pos(n), ft(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    pos[--a[i]] = i;
  }
  vector<long long> cnt_inv(n);
  for (int i = 0; i < n; ++i) {
    cnt_inv[i] = sum(pos[i], n - 1, ft);
    inc(pos[i], ft);
  }
  for (int i = 1; i < n; ++i) {
    cnt_inv[i] += cnt_inv[i - 1];
  }
  set<int> l, r;
  long long suml = 0, sumr = 0;
  vector<long long> ans(n);
  for (int i = 0; i < n; ++i) {
    if (r.empty() || *r.begin() > pos[i]) {
      l.insert(pos[i]);
      suml += pos[i];
    } else {
      r.insert(pos[i]);
      sumr += pos[i];
    }
    while (l.size() < r.size()) {
      sumr -= *r.begin();
      suml += *r.begin();
      l.insert(*r.begin());
      r.erase(r.begin());
    }
    while (r.size() < l.size()) {
      suml -= *l.rbegin();
      sumr += *l.rbegin();
      r.insert(*l.rbegin());
      l.erase(--l.end());
    }
    long long d = *r.begin();
    long long cntl = l.size();
    long long cntr = r.size() - 1;
    sumr -= d;
    ans[i] = (sumr - suml) + d * (cntl - cntr) -
             (cntl * (cntl + 1) / 2 + cntr * (cntr + 1) / 2) + cnt_inv[i];
    sumr += d;
  }
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << ' ';
  }
  return 0;
}
