#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<bool,bool> fP;
typedef pair<ll,P> iP;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
const int SEGLEN=1<<19;

vector<int> segtree(SEGLEN*2);

void add(int ind, int num){
    ind+=SEGLEN;
    while(ind){
        segtree[ind]+=num;
        ind/=2;
    }
} 

ll get(int l, int r){
    l+=SEGLEN;
    r+=SEGLEN;
    ll res=0;
    while(r>l){
        if(l%2){
            res+=segtree[l];
            l++;
        }
        l/=2;
        if(r%2){
            res+=segtree[r-1];
        }
        r/=2;
    }
    return res;
}


int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    ll rev=0;
    for(int j=0;j<n;j++){
        rev+=j-get(0,a[j]);
        add(a[j],1);
    }
    vector<ll> ans(n);
    ans[0]=rev;
    for(int i=0;i<n-1;i++){
        ans[i+1]=ans[i]+n-1-2*a[i];
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
    
}
#include<bits/stdc++.h>
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define pi 3.141592653589
#define MOD 1000000007
#define to() int tt; cin>>tt; while(tt--)
#define pb push_back
#define in insert
#define mp make_pair
#define ff first
#define ss second
#define si(s) s.size()
#define fori(it,v) for(it=v.begin();it!=v.end(); it++)
#define for1(i,low,high) for(int i=low;i<high;i++)
#define for2(i,low,high) for(int i=low;i<=high;i++)
#define rev(i,high,low)  for(int i=high;i>=low ;i--)
#define all(x) x.begin(), x.end()
#define fil(x,i) memset(x,i,sizeof(x));
#define setbits(x) __builtin_popcount(x)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
void i_o() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
#endif
}
const int N=3e5+6;
ll bit[N];

void add(int idx,ll val){
	for(;idx<N;idx+=idx&-idx) bit[idx]+=val;
}

ll sum(int idx){
	ll res=0;
	for(;idx>0;idx-=idx&-idx)
			res+=bit[idx];
	return res;
}

int main()
{
    boost; i_o();
    int n;
    cin>>n;
    vector<ll>v(2*n);
    vector<ll>ans(n);
    for(int i=0;i<n;i++){cin>>v[i]; v[i]++;}
    for1(i,n,2*n) v[i]=v[i-n];
	ll tot=0;
	for(int i=2*n-1;i>=n;i--){
		tot+=sum(v[i]-1);
		add(v[i],1LL);
	}
	ans[0]=tot;
	for(int i=n-1;i>0;i--){		
		tot-=(sum(n+1)-sum(v[i]));
		tot+=sum(v[i]-1);
		ans[i]=tot;
	}
	for1(i,0,n) cout<<ans[i]<<endl;
	cout<<endl;


    return 0;
}

