#include <bits/stdc++.h>
using namespace std;
long long n;
const long long MAX = 2e5 + 5;
long long fenw[MAX];
void update(long long x, long long val) {
  for (; x <= n; x += x & -x) fenw[x] += val;
}
long long query(long long x) {
  long long sum = 0;
  for (; x > 0; x -= x & -x) sum += fenw[x];
  return sum;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long a;
  cin >> n;
  vector<long long> v(n + 1), cnt1(n + 1), cnt2(n + 1);
  set<long long> st;
  set<long long>::iterator it;
  for (long long i = 1; i <= n; i++) {
    cin >> a;
    v[a] = i;
  }
  long long medVal = v[1], medPos = 1;
  for (long long i = 1; i <= n; i++) {
    a = v[i];
    st.insert(a);
    update(a, 1);
    cnt1[i] = cnt1[i - 1] + i - query(a);
    cnt2[i] = cnt2[i - 1];
    if (i == 1) continue;
    long long pos = query(a);
    if (a < medVal) {
      medPos++;
      cnt2[i] += medVal - a - medPos + pos;
      cnt2[i] -= pos - 1;
    } else {
      cnt2[i] += a - medVal - pos + medPos;
      cnt2[i] -= i - pos;
    }
    long long lt = medPos - 1;
    long long rt = i - medPos;
    if (abs(rt - lt) <= 1) {
      continue;
    } else if (rt > lt) {
      it = st.upper_bound(medVal);
      cnt2[i] -= abs(medVal - *it) - 1;
      medVal = *it;
      medPos++;
    } else {
      it = st.lower_bound(medVal);
      it--;
      cnt2[i] -= abs(medVal - *it) - 1;
      medVal = *it;
      medPos--;
    }
  }
  for (long long i = 1; i <= n; i++) cout << cnt1[i] + cnt2[i] << " ";
  cout << "\n";
  return 0;
}
