//Common Header Simple over C++11
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define memset0(x) memset((x),0,sizeof(x));
//#define endl '\n'
#define count2(x) __builtin_popcount(x)
#define countleadingzero(x) __builtin_clz(x)
#define dd(x) cerr << #x << " = " << x << ' ';
#define de(x) cerr << #x << " = " << x << endl;
//inline char nc() {
//  static char buf[1000000], *p = buf, *q = buf;
//  return p == q && (q = (p = buf) + fread(buf, 1, 1000000, stdin), p == q)
//             ? EOF
//             : *p++;
//}
inline ll rd(){//LLONG_MIN LMAX=9,223,372,036,854,775,807
    ll s=0,w=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0' && ch<='9')s=s*10+ch-'0',ch=getchar();
    return s*w;
}
const int N=3e5+1;
const int maxn=2e5+1;
int tot;
struct seg{
	int root,ls,rs;
	long long val;
}tre[maxn*100];
inline void insert(int &now,int l,int r,int x,int val){//单点插入 
	if(!now) now=++tot;
	tre[now].val+=val;
	if(l==r) return ; 
	const int mid=(l+r-1)/2;//因为可能修改负数位置的值，求mid时不能用(cl+cr)/2而要用(cl+cr-1)/2 
	if(x<=mid)insert(tre[now].ls,l,mid,x,val);
	else insert(tre[now].rs,mid+1,r,x,val);
}
int L=-1e6,R=1e6;
inline long long ask(int l,int r,int& now,int cl=L,int cr=R){//区间询问 
    if(!now) now=++tot;
	if(cl>r||cr<l)    return 0;
    else if(cl>=l&&cr<=r)    return tre[now].val;
    else{
        int mid=(cl+cr-1)/2;
        return ask(l,r,tre[now].ls,cl,mid)
		+ask(l,r,tre[now].rs,mid+1,cr);
    }
}
inline void ins(int v){//单点插入 
	insert(tre[1].root,L,R,v,1); //根节点插入 值域L-R +1
}
inline void remove(int v){//单点删除 
	insert(tre[1].root,L,R,v,-1);//根节点插入 值域L-R +1
}
inline long long countless(int v){//查小于v的有多少个 
	return ask(L,v-1,tre[1].root);//计数[L,v-1]的桶 
}
inline long long countgreat(int v){//查大于v的有多少个 
	return ask(v+1,R,tre[1].root);//计数[v+1,R]的桶 
}
inline int Rank(int v){//查数是第几大 
	return countless(v)+1;//计数[L,v-1]的桶+1 
}
inline int kth(int &now,int l,int r,int k){//查第k大的数 
	if(l==r) return l;
	int mid=(l+r-1)/2;
	if(tre[tre[now].ls].val>=k){
		return kth(tre[now].ls,l,mid,k);
	}
	else{
		return kth(tre[now].rs,mid+1,r,k-tre[tre[now].ls].val);
	}
}
inline int pre(int v){//前驱 
	int t=countless(v);
	return kth(tre[1].root,L,R,t);
} 
inline int suc(int v){//后继 
	int t=tre[1].val-countgreat(v)+1;
	return kth(tre[1].root,L,R,t);
}
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n;
	cin>>n;
	deque<int>dq;
	for(int i=1;i<=n;++i){
		int fafa;
		cin>>fafa;
		dq.push_back(fafa+1);
	}
	vector<ll>ans;
	ll now=0;
	for(int i=n-1;i>=0;--i){
		now+=countless(dq[i]);
		ins(dq[i]);
	}
	ans.push_back(now);
	for(int i=1;i<n;++i){
		int FR=dq.front();
		dq.pop_front();
		now-=countless(FR);
		dq.push_back(FR);
		now+=countgreat(FR);
		ans.pb(now);
	}
	for(auto i:ans)cout<<i<<'\n';
	return 0;
}


//#####   #####   #####   #####   #####   #       #####   #   #//
//#   #   #   #   #       #       #   #   #       #   #   ## ##//
//#####   #####   #####   #       #####   #       #####   # # #//
//##      #   #       #   #       #   #   #       #   #   #   #//
//# #     #   #       #   #       #   #   #       #   #   #   #//
//#  #    #   #       #   #       #   #   #       #   #   #   #//
//#   #   #   #   #####   #####   #   #   #####   #   #   #   #//


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define pbds tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define ppb pop_back
#define cs(n) cout<<n<<" "
#define rep(i,j,k) for(int i=j;i<k;i++)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define de2(x) cout << #x << " " << x << endl;
#define rept(it,v) for(auto it=v.begin(); it!=v.end(); it++)
#define sz(v) (int)(v.size())
#define printdec(x,y) cout<< fixed << setprecision(y) << x
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define deb(x) cout<<#x<<" : "<<x<<"\n"
#define int long long
template<typename... T>
void read(T&... args) {
	((cin >> args), ...);
}
template<typename... T>
void write(T&&... args) {
	((cout << args << " "), ...);
}
template<typename... T>
void writen(T&&... args) {
	((cout << args << "\n"), ...);
}
template<typename... T>
void cn(T&&... args) {
	((cout << args << " "), ...);
	cout << "\n";
}
ll bin(ll a, ll b, ll mod)
{
	if (b == 0)
		return 1;
	if (b % 2 == 0)
		return bin((a * a) % mod , b / 2 , mod) % mod;
	return ((a % mod) * (bin((a * a) % mod , b / 2 , mod) % mod)) % mod;
}
void solve()
{
	int n;
	read(n);
	int ar[n + 5];
	rep(i, 0, n) {
		read(ar[i]);
	}
	pbds s;
	s.insert(ar[0]);
	int cnt = 0;
	rep(i, 1, n) {
		s.insert(ar[i]);
		int inv = s.order_of_key(ar[i] + 1);
		cnt += sz(s) - inv;
	}
	cout << cnt << "\n";
	rep(i, 0, n - 1) {
		cnt -= ar[i];
		cnt += (n - 1 - ar[i]);
		cout << cnt << "\n";
	}
}
signed main()
{
	fastio;
	int t;
	t = 1;
	// cin >> t;
	while (t--)
	{
		solve();
	}
#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
	return 0;
}