#include<bits/stdc++.h>

using namespace std;
 
#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   N     =  3e5+5;
const ll   mod   =  1e9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll n, a[N], l[N], r[N];

ll tree[N] = {};
 
void update(int idx, int val){ 
    idx++;
    while(idx <= N-2){ 
        tree[idx] += val;
        idx += idx & (-idx); 
    } 
} 
 
ll query(int idx){
    idx++;
    ll sum = 0;
    while(idx > 0){ 
        sum += tree[idx];
        idx -= idx & (-idx); 
    } 
    return sum; 
}

void solve(){
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		l[i] = query(a[i]), r[i] = a[i] - l[i];
		ans += r[i];
		update(a[i], 1);
	}
	cout << ans << "\n";
	for(int i = 1; i < n; i++){
		ans += n - i - 2 * r[i];
		ans += i - 1 - 2 * l[i];
		cout << ans << "\n";
	}
}

int main(){
	GODSPEED;
	int test = 1;
	//cin >> test;
	for(int i = 1; i <= test; i++){
		solve();
	}
	#ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v){
    if(v.empty()){
        os<<"{ }";
        return os;
    }
    os<<"{"<<v.front();
    for(auto itr=++v.begin();itr!=v.end();itr++){
        os<<", "<<*itr;
    }
    os<<"}";
    return os;
}

template<typename T_first,typename T_second>
ostream& operator<<(ostream& os,const pair<T_first,T_second>& P){
    os<<"("<<P.first;
    os<<", "<<P.second;
    os<<")";
    return os;
}

template<typename T>
class BIT{
public:
    int n;
    vector<T> bit; // 1-indexed

    BIT():n{0}{}
    BIT(int n_in):n{n_in}{
        bit.assign(n+1,0);
    }

    void init_u(){
        for(int i=1;i<n;i++)if(i+(i&-i)<=n) bit[i+(i&-i)]+=bit[i];
    }

    void add(int k,T w){
        if(k<=0) return;
        for(int i=k;i<=n;i+=i&-i) bit[i]+=w;
    }

    //(0,k]
    T sum(int k) const{
        T res=0;
        for(int i=k;i>0;i-=i&-i) res+=bit[i];
        return res;
    }

    //(l,r] 累積和区間と同じ
    T secsum(int l,int r) const{
        return sum(r)-sum(l);
    }

    //各要素は非負整数とする
    //w->w+1でupper_bound
    int lower_bound(T w) const{
        if(sum(n)<w) return n+1; //範囲外
        int idx=0,r=1;
        while(r<n) r<<=1;
        for(int len=r;len>0;len>>=1){
            if(idx+len<n && bit[idx+len]<w){
                w-=bit[idx+len];
                idx+=len;
            }
        }
        return idx+1;
    }
};

int main(){
    ll n; cin>>n;
    vector<ll> a(n,0);
    rep(i,n) cin>>a[i];
    BIT<ll> bit(n+1);
    ll ans=0;
    rep(i,n){
        ans+=bit.secsum(a[i]+1,n+1);
        bit.add(a[i]+1,1);
    }
    cout<<ans<<endl;
    rep(i,n-1){
        ans=ans-a[i]+(n-1-a[i]);
        cout<<ans<<endl;
    }
}