#include <bits/stdc++.h>
using namespace std;
long long tree[222222 + 20];
long long read(int idx) {
  long long sum = 0;
  while (idx > 0) {
    sum += tree[idx];
    idx -= (idx & -idx);
  }
  return sum;
}
void update(int idx, int n) {
  while (idx <= n) {
    tree[idx]++;
    idx += (idx & -idx);
  }
}
int pos[222222 + 2];
void Update(int x, set<int>* left_set, set<int>* right_set,
            long long* sum_left_heap, long long* sum_right_heap) {
  if (!right_set->empty() && x > *right_set->begin()) {
    right_set->insert(x);
    (*sum_right_heap) += x;
  } else if (!left_set->empty() && x < *left_set->rbegin()) {
    left_set->insert(x);
    (*sum_left_heap) += x;
  } else {
    left_set->insert(x);
    (*sum_left_heap) += x;
  }
  while (right_set->size() > left_set->size()) {
    int x = *right_set->begin();
    right_set->erase(x);
    left_set->insert(x);
    (*sum_right_heap) -= x;
    (*sum_left_heap) += x;
  }
  while (left_set->size() > right_set->size() + 1) {
    int x = *left_set->rbegin();
    left_set->erase(x);
    right_set->insert(x);
    (*sum_left_heap) -= x;
    (*sum_right_heap) += x;
  }
}
long long B(long long x) { return (x * (x + 1)) / 2; }
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    pos[x] = i;
  }
  int minn = -1;
  int maxx = -1;
  long long total_invs = 0;
  set<int> left_set;
  set<int> right_set;
  long long sum_left_heap = 0;
  long long sum_right_heap = 0;
  for (int i = 1; i <= n; i++) {
    Update(pos[i], &left_set, &right_set, &sum_left_heap, &sum_right_heap);
    long long med = *left_set.rbegin();
    long long k1 = left_set.size();
    long long k2 = right_set.size();
    total_invs += i - 1 - read(pos[i]);
    update(pos[i], n);
    printf("%lld ", med * k1 - sum_left_heap - B(k1 - 1) + sum_right_heap -
                        B(k2 - 1) - med * k2 - k2 + total_invs);
  }
  cout << endl;
}
