#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll merge_cnt(vector<int> &a) {
    int n = a.size();
    if (n <= 1) { return 0; }

    ll cnt = 0;
    vector<int> b(a.begin(), a.begin()+n/2);
    vector<int> c(a.begin()+n/2, a.end());

    cnt += merge_cnt(b);
    cnt += merge_cnt(c);

    int ai = 0, bi = 0, ci = 0;
    // merge の処理
    while (ai < n) {
        if ( bi < b.size() && (ci == c.size() || b[bi] <= c[ci]) ) {
            a[ai++] = b[bi++];
        } else {
            cnt += n / 2 - bi;
            a[ai++] = c[ci++];
        }
    }
    return cnt;
}

int main() {
    int n;
    cin >> n;

    vector<int> a(n);

    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> a_cp = a;

    ll cnt = merge_cnt(a_cp);
    vector<ll> ans(n);
    ans[0] = cnt;
    for (int i = 0; i < n; i++) {
        // cout << cnt << endl;
        int p = a[n-i-1];
        // cout << cnt << endl;
        cnt = cnt + p - (n - 1 - p);
        if (i < n - 1) ans[n-i-1] = cnt;
    }

    for (auto an: ans) cout << an << endl;

    return 0;
}
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define NUM 300005

ll first_N;
ll uniformity[6*NUM],partial[6*NUM];
ll N = 1;
ll A[NUM];
ll BIT[NUM];

void bitadd(ll loc,ll value){

	BIT[loc] += value;

	loc += loc & -loc; //最後の1ビットを足した場所が次の★更新★場所

	while(loc <= first_N){
		BIT[loc] += value;
		loc += loc & -loc;
	}
}

ll BITSum(ll loc){

	ll sum = BIT[loc];

	loc -= loc & -loc; //最後の1ビットを引いた場所が次の★加算★場所

	while(loc > 0){
		sum += BIT[loc];
		loc -= loc & -loc;
	}
	return sum;
}


void init(){
	while(N < first_N)N *= 2;
}

void add(ll left,ll right,ll value,ll node_id,ll node_left,ll node_right){

	if(right <= node_left || left >= node_right)return;
	else if(left <= node_left && right >= node_right){
		uniformity[node_id] += value;
	}else{
		partial[node_id] += (min(right,node_right)-max(left,node_left))*value;
		add(left,right,value,2*node_id+1,node_left,(node_left+node_right)/2);
		add(left,right,value,2*node_id+2,(node_left+node_right)/2,node_right);
	}
}

ll getSum(ll left,ll right,ll node_id,ll node_left,ll node_right){
	if(right <= node_left || left >= node_right)return 0;
	else if(left <= node_left && right >= node_right){
		return (node_right-node_left)*uniformity[node_id]+partial[node_id];

	}else{
		ll sum = (min(right,node_right)-max(left,node_left))*uniformity[node_id];

		sum += getSum(left,right,2*node_id+1,node_left,(node_left+node_right)/2);
		sum += getSum(left,right,2*node_id+2,(node_left+node_right)/2,node_right);
		return sum;
	}
}

int main(){

	scanf("%lld",&first_N);

	for(ll i = 0; i < first_N; i++){

		scanf("%lld",&A[i]); //1～first_N
		A[i]++;
	}

	for(ll i = 0; i <= first_N; i++){

		BIT[i] = 0;
	}

	init();

	for(ll i = 0; i <= 2*N-2; i++){
		uniformity[i] = 0;
		partial[i] = 0;
	}

	ll ans = 0;

	for(ll i = 0; i < first_N; i++){

		ll tmp = i-BITSum(A[i]);
		ans += tmp;
		bitadd(A[i],1);
		add(A[i],A[i]+1,tmp,0,0,N);
	}

	printf("%lld\n",ans);

	int head = 0;

	for(ll loop = 0; loop < first_N-1; loop++){

		ll tmp = first_N-(A[head]); //A[head]より大きい数の個数
		ll minus = getSum(A[head],A[head]+1,0,0,N);

		//printf("A[head]:%lld loop:%lld tmp:%lld minus:%lld\n",A[head],loop,tmp,minus);
		add(A[head],A[head]+1,-minus+tmp,0,0,N); //
		if(A[head] >= 2){

			add(1,A[head],-1,0,0,N);
		}
		printf("%lld\n",getSum(1,first_N+1,0,0,N));

		head++;
	}

	return 0;
}
