#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int N = 400005;
int a[N],pos[N],fen[5][N];
void upd(int tp,int idx,int val){
    while(idx < N){
        fen[tp][idx] += val;
        idx+=(idx&(-idx));
    }
}
ll get(int tp,int idx){
    ll s = 0;
    while(idx){
        s += fen[tp][idx];
        idx -= (idx&(-idx));
    }
    return s;
}
ll find(int l,int r,int x){
    ll res=0;
    while (l <= r){
        int mid = (l + r) >> 1;
        if (get(1,mid)*2 <= x) {
            res = mid;
            l = mid + 1;
        }
        else r = mid - 1;
    }
    return res;
}
main (){
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n;
    cin>>n;
    
    for (int i=1;i<=n;i++)
        cin>>a[i],pos[a[i]] = i;
    
    int l = n+1,r = 0;
    ll inversions = 0,ans = 0;
    for (int k=1;k<=n;k++){
        l = min(l,pos[k]),r = max(r,pos[k]);
        inversions += k - 1 - get(1,pos[k]);
        upd(1,pos[k],1),upd(2,pos[k],pos[k]);
        
        if (k == 1) {
            cout<<0<<" ";
            continue;
        }
        
        ll id = find(l,r,k);
        ll c1 = get(1,id),c2 = k - c1;
        
        ll L = c1 * id - get(2,id) - c1*(c1 - 1)/2;
        ll R = get(2,n) - get(2,id) - id*c2 - c2*(c2 + 1)/2;
        ans = inversions + L + R;
        cout<<ans<<" ";
    }
}