#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#include <set>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)n; i++)

#define V vector<int>
#define P pair<int,int>
#define INF 1000000007
#define MOD	10000
typedef long long LL;

#define SIZE 1000000
int BIT[SIZE];

void add(int i) {
	if (i >= SIZE) return;
	BIT[i]++;
	add(i + (i & (-i)));
}

int sum(int i) {
	if (i == 0)	return 0;
	return BIT[i] + sum(i - (i & (-i)));
}

int main() {
	int N;
	V A;
	cin >> N;
	REP(i, N) {
		int a;
		cin >> a;
		A.push_back(a + 1);
	}
	LL inversions = 0;
	REP(k, N) {
		int a = A[k];
		inversions += ((LL)k - (LL)sum(a));
		add(a);
	}
	REP(k, N) {
		cout << inversions << endl;
		int cnt = (N - A[k]) - (A[k] - 1);
		inversions += (LL)cnt;
	}
}
#include<bits/stdc++.h>

using namespace std;

#define enviar {ios_base::sync_with_stdio(false);}
#define aiuda {cin.tie(NULL); cout.tie(NULL);} 

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) ;F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
#define exacto(v) cout << setprecision(v) << fixed;

#define ll long long
#define eb emplace_back
#define em emplace
#define ef emplace_front
#define f first
#define s second
#define big greater<ll>()



#define ar(v)  array<int,v>
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x).size()
#define meminf(v) memset(v, 0x7f , sizeof(v))
#define mem(v,x) memset(v , x , sizeof v);
#define ai(a, n) for (int ele = 0; ele < n; ele++) cin >> a[ele];
#define ao(a, n) {for (int ele = 0; ele < (n); ele++) { if (ele) cout << " "; cout << a[ele]; } cout << '\n';}
#define readgraph(list, edges) for (int i = 0; i < edges; i++) {int n1, n2; cin >> n1 >> n2; n1--; n2--; list[n1].eb(n2); list[n2].eb(n1);}
 


template<class T> bool umin(T& a, const T& b) { return b<a?a=b, 1:0; }
template<class T> bool umax(T& a, const T& b) { return a<b?a=b, 1:0; } 

string to_string(bool b) {return b?"true":"false"; }

string to_string(char c) { return string(1, c);}

string to_string(const char* s) { return string(s); }

string to_string(string s) { return s; }

template<class T> string to_string(T v) { bool f=1; string res; EACH(x, v) { if(!f) res+=' '; f=0; res+=to_string(x); } return res; }

template<class A> void write(A x) { cout << to_string(x); }

void print() { write("\n"); }

template<class H, class... T> void print(const H& h, const T&... t) {  write(h); if(sizeof...(t)) write(' '); print(t...); }




typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;



const ll mod = 1e9 + 7;
const ll maxsize = 3e5 + 10;
// const (size, caracter) 

 

//ll n, m ,k , nc;

ll cnt[maxsize];
//ll a[maxsize], b[maxsize], p[maxsize];


//ll pre[maxsize];
struct FenwickTree {
    vector<int> bit;  // binary indexed tree
    int n;

    FenwickTree(int _n) {
        this->n = _n;
        bit.assign(n, 0);
    }

    FenwickTree(vector<int> a) : FenwickTree(a.size()) {
        for (size_t i = 0; i < a.size(); i++)
            add(i, a[i]);
    }

    int sum(int r) {
        int ret = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            ret += bit[r];
        return ret;
    }

    int sum(int l, int r) {
        return sum(r) - sum(l - 1);
    }

    void add(int idx, int delta) {
        for (; idx < n; idx = idx | (idx + 1))
            bit[idx] += delta;
    }
};

ll n, m ,k , nc;
ll a[maxsize];
void solve()
{	
	cin >> n;
	FenwickTree  f(n);

	ll ans = 0;
	FOR(i , n){
		ll u ; cin >> u;
		a[i] = u;
		ll t = f.sum(u, n-1);
		ans += t;
		cnt[i] = t;
		//print(u,  f.sum(u), ans);
		f.add(u, 1);
	}
	
	print(ans);	
	
	FOR(i ,   n - 1)
	{
		ans -= a[i];
		ans += (n -1 )- a[i];
		print(ans);
	}	
	
	
		
}

int main(){
	
	enviar aiuda
	
	int t = 1;
	//cin >> t;

    while(t--)  solve();
    
	return 0;
} 
	  
	 
 

	 

 
