#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define tr(it,a) for(auto it:a)
#define pob pop_back
#define pf push_front
#define pof pop_front
#define umin(x,y) (x=min(x,(y)))
#define umax(x,y) (x=max(x,(y)))
#define mid ((l+r)/2)
#define lch (idx*2+1)
#define rch (idx*2+2)
//
#include<bits/stdc++.h>
#define int int_fast64_t
using namespace std;
typedef pair<int,int> pii;
#define REP(i,j,k) for(int i=(j);i<(k);++i)
#define RREP(i,j,k) for(int i=int(j)-1;i>=(k);--i)
#define ALL(a) a.begin(),a.end()
#define pb push_back
#define f first
#define s second
#define endl '\n'
// #define __debug
#ifdef __debug
	#define IOS (void)0
	#define pr(...) cerr<<__VA_ARGS__
	#define ar(a,s,t) {REP(zy,s,t)pr(a[zy]<<' ');pr(endl);}
#else
	#define IOS cin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false)
	#define pr(...) (void)0
	#define ar(...) (void)0
#endif
//
const int maxn=2e5+9;
int n,p[maxn],t[maxn];
set<int>s1,s2;

namespace fw{
	int dat[maxn];
	void init(){
		memset(dat,0,sizeof dat);
	}
	void add(int i){
		for(;i<=n;i+=i&-i){
			++dat[i];
		}
	}
	int sum(int i){
		int re=0;
		for(;i>0;i-=i&-i){
			re+=dat[i];
		}
		return re;
	}
}

main(){
	IOS;
	fw::init();
	cin>>n;
	REP(i,0,n){
		cin>>p[i];
		t[--p[i]]=i;
	}
	int all=0,rev=0;
	REP(i,0,n){
		if(s1.size()){
			auto it=prev(s1.end());
			//all+=abs(t[i]-*it);
			if(t[i]<*it)all+=(*it-s1.size())-t[i],s1.insert(t[i]);
			else all+=t[i]-(*it+s2.size()+1),s2.insert(t[i]);
			while(s1.size()+1<s2.size()){
				it=prev(s1.end());
				all+=((int)s1.size()-(int)s2.size())*(*s2.begin()-*it-1);
				s1.insert(*s2.begin());
				s2.erase(s2.begin());
			}
			while(s2.size()+1<s1.size()){
				it=prev(s1.end());
				all+=((int)s2.size()-(int)s1.size()+2)*(*s2.begin()-*it-1);
				s2.insert(*it);
				s1.erase(it);
			}
		}else s1.insert(t[i]);
		rev+=fw::sum(n-t[i]);
		//cout<<all<<"-"<<(i+1)*i/2<<"+"<<rev<<endl;
		cout<<all+rev<<" ";
		fw::add(n-t[i]);
	}
}