#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
	int res = 1;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res % p;
}
int lcm(int a, int b)
{
	return a / __gcd(a, b) * b;
}
void solve()
{
	int n;
	cin >> n;
	int a[n];
	ordered_set<int> se;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		int g = se.order_of_key(a[i]);
		ans += i - g;
		se.insert(a[i]);
	}
	cout << ans << endl;
	for (int i = 1; i < n; i++) {
		ans += (n - a[i - 1] - 1) - a[i - 1];
		cout << ans << endl;
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int tc;
	tc = 1;
#ifndef ONLINE_JUDGE
	freopen("inputf.txt", "r", stdin);
	freopen("outputf.txt", "w", stdout);
#endif
	// cin >> tc;
	while (tc--)
	{

		solve();

	}

	return 0;
}
// 解き直し.
// https://atcoder.jp/contests/abc190/editorial/631
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL a[303030];

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT{
    int n;
    vector<T> d;
    BIT(int n = 0) : n(n), d(n + 1) {}
    void add(int i, T x = 1){
        for(i++; i <= n; i += i & -i) d[i] += x;
    }
    T sum(int i){
        T x = 0;
        for(i++; i; i -= i & -i) x += d[i];
        return x;
    }
    T sum(int l, int r){
        return sum(r - 1) - sum(l - 1);
    }
};

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    rep(i, N) scanf("%lld", &a[i]);
    
    // 2. 転倒数(数列 A) を 計算.
    BIT<LL> ft(N + 1);
    LL per = 0;
    rep(i, N){
        // 2-1. 位置 a[i] に, 1 を 加算.
        ft.add(a[i], 1LL);
        
        // 2-2. 区間[a[i] + 1, N] の 合計は？
        LL t = ft.sum(a[i] + 1, N + 1);
        
        // 2-3. 集計.
        per += t;
    }
    
    // 3. 転倒数(数列 B) を 計算しながら出力.
    LL ans = per;
    rep(i, N){
        // 3-1. 出力.
        printf("%lld\n", ans);
        
        // 3-2. 差分更新(※解説通り).
        ans += (LL)(N - 1 - 2 * a[i]);
    }
    return 0;
    
}