//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>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type , less<T> , rb_tree_tag , tree_order_statistics_node_update> ;
 
#define ll long long
#define PI 3.14159265
ll mod = 1000000007;
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

int main()  
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll n;
    cin >> n;
    ll arr[n];
    for(int i = 0; i < n; i++)  {
        cin >> arr[i];
    }
    ordered_set<int> st;
    ll ans = 0;
    for(int i = 0; i < n; i++)  {
        ans += arr[i];
        if(st.size() > 0)   {
            ans -= st.order_of_key(arr[i]);
        }
        st.insert(arr[i]);
    }
    cout << ans << "\n";
    for(int i = 0; i < n-1; i++)    {
        ans -= arr[i];
        ans += n-1 - arr[i];
        cout << ans << "\n";
    }  
    
}
    
    

