#include <bits/stdc++.h>
#define maxn 300001
using namespace std;
typedef long long LL;

int n;
LL ans;
int ar[maxn];
int tree[maxn];

void update(int x) {
	while(x <= n) {
		tree[x]++;
		x += (x&(-x));
	}
}

int query(int x) {
	int sum = 0;
	while(x) {
		sum += tree[x];
		x -= (x&(-x));
	}
	return sum;
}

int main() {
	scanf("%d",&n);
	for( int i = 1 ; i <= n ; i++ ) {
		scanf("%d",&ar[i]);
		update(++ar[i]);
		ans += i - query(ar[i]);
	}
	printf("%lld ",ans);
	for( int i = 1 ; i < n ; i++ ) {
		ans += n+1 - 2*ar[i];
		printf("%lld ",ans);
	}
	return 0;
}
// Author:   old_school
// Created:  30.01.2021 17:30:27

#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma") 
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define lld               long long int
#define ld                long double
#define pb                push_back
#define ppb               pop_back 
#define mp                make_pair
#define F                 first
#define S                 second
#define nl                '\n'
#define all(c)            (c).begin(),(c).end()
#define rall(c)           (c).rbegin(),(c).rend()
#define sz(c)             (c).size()
#define tr(x,a)           for(auto &a : x)
#define psnt(x,a)         (x).find(a)!=(x).end()
#define vpsnt(x,a)        find(all(x),a)!=(x).end()
#define MOD               1000000007
#define tod               1
#define pi                3.1415926536
#define itr(i,a,b)        for(lld i=a;i<=b;i++)
#define itrn(i,a,b)       for(lld i=a;i>=b;i--)
#define iot(n)            for(lld i=0;i<n;i++)
#define pls(n,arr)        lld arr[n]; iot(n)  cin>>arr[i];
#define bye               fflush(stdout)

typedef pair<lld,lld>     pii;
typedef pair<string,lld>  psi;

template <typename T>
bool mycomp(T x,T y){ 
   return (x==y);  //give your condition here
}
bool paircomp(const pair<lld,lld> &x,const pair<lld,lld> &y){ 
return x.second<y.second;
}
lld _mergeSort(lld arr[], lld temp[],  
                 lld left, lld right); 
lld merge(lld arr[], lld temp[], lld left,  
                   lld mid, lld right); 
lld mergeSort(lld arr[], lld array_size) 
{ 
    lld temp[array_size]; 
    return _mergeSort(arr, temp, 0, array_size - 1); 
} 
lld _mergeSort(lld arr[], lld temp[],  
                 lld left, lld right) 
{ 
    lld mid, inv_count = 0; 
    if (right > left) { 
    
        mid = (right + left) / 2; 
  
        inv_count += _mergeSort(arr, temp,  
                                left, mid); 
        inv_count += _mergeSort(arr, temp,  
                             mid + 1, right); 
 
        inv_count += merge(arr, temp, left,  
                           mid + 1, right); 
    } 
    return inv_count; 
} 
  
lld merge(lld arr[], lld temp[], lld left, 
          lld mid, lld right) 
{ 
    lld i, j, k; 
    lld inv_count = 0; 
  
    i = left; 
    j = mid; 
    k = left; 
    while ((i <= mid - 1) && (j <= right)) { 
        if (arr[i] <= arr[j]) { 
            temp[k++] = arr[i++]; 
        } 
        else { 
            temp[k++] = arr[j++]; 

            inv_count = inv_count + (mid - i); 
        } 
    } 

    while (i <= mid - 1) 
        temp[k++] = arr[i++]; 

    while (j <= right) 
        temp[k++] = arr[j++]; 
  

    for (i = left; i <= right; i++) 
        arr[i] = temp[i]; 
  
    return inv_count; 
} 
void solve(){
	lld n; cin>>n;
	pls(n,a);
	lld b[n];
	iot(n) b[i]=a[i];
    lld ans = mergeSort(a, n); 
    cout<<ans<<nl;
    iot(n-1){
    	ans+=(n-2*b[i]-1);
    	cout<<ans<<nl;
    }
}
int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
      lld t=1;// cin>>t;  
      while(t--){
            solve();
            cout<<endl;
      }
}

