#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <ctime>

#define pb push_back
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pii pair < int, int >
#define ull unsigned long long
#define pll pair < ll, ll >
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define all(s) s.begin(), s.end()
#define sz(a) (int)a.size()
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <ctime>

#define pb push_back
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pii pair < int, int >
#define ull unsigned long long
#define pll pair < ll, ll >
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define all(s) s.begin(), s.end()
#define sz(a) (int)a.size()

const int inf = (1 << 29) - 1;
const int maxn = (int)2e5 + 10; //maximum + 10
const int mod = (int) 1e9 + 7;
using namespace std;
int n;
int p[maxn];
ll t[2][maxn];
int rp[maxn];
void upd(int id, int pos, int val) {
	for(int i = pos; i <= n; i |= i+1) t[id][i] += val;
}
ll get(int id, int pos) {
	ll res = 0;
	while(pos >= 0) {
		res += t[id][pos];
		pos = (pos&(pos+1)) - 1;
	}
	return res;
}
set<int> s1, s2;
ll inv;
ll add(int p, int k) {
	inv += get(0, n) - get(0, p);
	upd(0, p, 1);
	upd(1, p, p);
	ll ans = inv;
	s2.insert(p);
	s1.insert(*s2.begin());
	s2.erase(s2.begin());
	if(s2.size()+2 <= s1.size()) {
		s2.insert(*(--s1.end()));
		s1.erase(--s1.end());
	}
	ll m = *(--s1.end());
	ll F = s1.size()-1;
	ll S = s2.size();
	ans += F * m - get(1, m-1) - F * (F+1ll)/2;
	ans += get(1, n) - get(1, m) - m * S - S * (S+1ll)/2;
	return ans;
}
void solve(){
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> p[i];
		rp[p[i]] = i;
	}
	for(int i = 1; i <= n; i++) {
		int pos = rp[i];
		cout << add(pos, i) << "\n";
	}

}
int main () {

    int t=1;
    //scanf("%d", &t);
    for(int i=1; i <= t; i++){
      //printf("Case #%d: ", i);
      solve();
    }

    return 0;
}


//* Wild.Stone - IIT Roorkee *

#include<bits/stdc++.h>
using namespace std;
   #ifndef WildStone
      #pragma GCC optimize("Ofast")
      #pragma GCC optimize("unroll-loops")
   #endif
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i)
#define max2(a,b)  ((a)>(b)?(a):(b))
#define min2(a,b)  ((a)<(b)?(a):(b))
#define all(x)  x.begin(),x.end()
#define sz(x)  (int)x.size()
#define ins insert
#define fi first
#define se second
#define pb emplace_back  //push_back
#define mp make_pair
#define endl '\n'

#ifdef WildStone
  template <typename T>
       void __p(T a) { cout << a << " "; }
  template <typename T, typename F>
       void __p(pair<T,F> a) { cout<<"{ "; __p(a.fi); __p(a.se); cout<<"}"; }
  template <typename T>
       void __p(vector<T> a) { cout<<"{ "; for(auto __it: a) { __p(__it); cout<<", "; } cout<<"}"; }
  template <typename T>
       void __p(set<T> a) {cout<<"{ "; for(auto __it: a) { __p(__it); cout<<", "; } cout<<"}"; }
  template <typename T,typename F>
       void __p(map<T,F> a) { cout<<"{ "; for(auto __it: a) { __p(__it.fi); cout<<"-> "; __p(__it.se); cout<<", "; } cout<<"}"; }

  template <typename Arg1>
       void __f(const char* name, Arg1&& arg1)             // for single trace argument
          { cout<<name<<" : "; __p(arg1); cout<<endl; }
  template <typename Arg1, typename ...Args>
       void __f(const char* names, Arg1&& arg1, Args&& ...args)  // for multiple trace arguments
          {
          	 int __bracket=0,__i=0; string __s;
          	 for(;;__i++)
          	 	  if(names[__i]==',' && __bracket==0)  break;
          	 	  else
          	 	  {  __s += names[__i];
          	 	  	     if(names[__i]=='(') __bracket++;
          	 	  	else if(names[__i]==')') __bracket--;
          	 	  }
             cout<<__s<<" : ";   __p(arg1); cout<<" | ";
             __f(names+(__i)+1,args...);
          }
   template <typename Arg1, typename Arg2>                          // for traversing array
        void __f(const char* name , Arg1 arg1[], Arg2&& arg2)
          {
             int __i=0;  string __s;
             for(;;__i++) if(name[__i]==',') break; else __s += name[__i];
             cout<<__s<<" : ";
             for(__i=0;__i<arg2;__i++) __p(arg1[__i]); cout<<endl;
          }
  #define trace(...) cout<<"LINE: "<<__LINE__<<" || "; __f( #__VA_ARGS__, __VA_ARGS__)
  clock_t clk=clock();
  #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
  #define trace(...);
  #define checktime();
#endif

typedef long long int ll;
typedef long double   ld;
typedef pair<int,int> pii;
typedef pair<ll,ll>   pll;
typedef vector<int>   vi;
typedef vector<ll>    vll;
typedef vector<pii>   vpii;
typedef vector<pll>   vpll;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set =  tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#define fbo find_by_order //--> *p.fbo(0), *p.fbo(1).... iterating like vector/array
#define ook order_of_key  //--> p.ook(element) : lowerbound binary search
  // (int)p.size();    // p.erase(value) --> erases element with that value

const ll mod = 1000000007;  //998244353;
const ll inf = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
const double PI  = acos(-1);

ll i,j,k;
void solve(void);
inline bool equal(double a, double b) { return fabs(a-b)<eps; }
// inline ll gcd(ll a, ll b) { a=abs(a); b=abs(b); while(a>0 && b>0) (a>b?a%=b:b%=a); return (a==0?b:a); }
// inline ll power(ll x, ll n, ll m = LLONG_MAX)
//        {  ll res=1;
//        	   while(n) { if(n&1) res=(res*x)%m;  x=(x*x)%m;  n >>= 1; }  return res;
//        }

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	cout<<fixed<<setprecision(10);
	int t = 1;
	// cin>>t;
	    while(t--)  solve();
	checktime();
	return 0;
}
#define N 200005

ll segt[4*N], arr[N];

void build(int node, int l, int r)  // sum segtree template
{
	if(l==r)
	{
		segt[node] = arr[l];
		return;
	}
	int m = (l+r)>>1;
    build(2*node, l, m);
    build(2*node+1, m+1, r);

    segt[node] = segt[2*node] + segt[2*node+1];
}

void update(int node, int l, int r, int pos, int val)
{
	if(l==r)
	{
		arr[pos] = val;
		segt[node] = val;
		return;
	}
	int m = (l+r)>>1;
	if(pos<=m) update(2*node, l, m, pos, val);
	else       update(2*node+1, m+1, r, pos, val);

	segt[node] = segt[2*node] + segt[2*node+1];
}

ll query(int node, int l, int r, int ql ,int qr)
{
	if( r<ql || l>qr || ql>qr) return 0;
	if( ql<=l && qr>=r) return segt[node];

	int m = (l+r)>>1;
	ll val1 = query(2*node, l, m , ql, qr);
	ll val2 = query(2*node+1, m+1, r, ql, qr);

	return (val1+val2);
}

void solve()
{
	ll n; cin>>n;
	ll p[n+1] = {0}, loc[n+1] = {0};
	rep(i,1,n)
	{
		cin>>p[i];
		loc[ p[i] ] = i;
	}

	ll inversion_count[n+1] = {0}, grp_count[n+1] = {0}, ans[n+1] = {0};

    ordered_set< int > s;

    rep(i,1,n)
    {
       s.ins(loc[i]);
       int pos = s.ook(loc[i]+1);

       inversion_count[i] = (sz(s) - pos);
       inversion_count[i] += inversion_count[i-1];

       update(1,1,n,loc[i],loc[i]);

       pos = sz(s) - 1;  pos /= 2;
       int median = *s.fbo(pos);

       ll sum1 = query(1,1,n,1,median-1);
       ll sum2 = query(1,1,n,median+1,n);
       ll ct1 = pos;
       ll ct2 = (sz(s) - pos - 1);

       grp_count[i] = (ct1*median - sum1) + (sum2 - ct2*median);
       grp_count[i] -= (ct1*(ct1+1))/2;
       grp_count[i] -= (ct2*(ct2+1))/2;

       ans[i] = inversion_count[i] + grp_count[i];
    }

    rep(i,1,n)
     cout<<ans[i]<<' '; cout<<endl;
}


#include "bits/stdc++.h"
#include <random>
using namespace std;
using ll    =long long;    using dd   =double;        using pll    =pair<ll, ll>;  using tll    =tuple<ll,ll,ll>;
using vll   =vector<ll>;   using vdd  =vector<dd>;    using vpll   =vector<pll>;   using vtll   =vector<tll>;
using vvll  =vector<vll>;  using vvdd =vector<vdd>;   using vvpll  =vector<vpll>;  using vvtll  =vector<vtll>;
using vvvll =vector<vvll>; using vvvdd=vector<vvdd>;  using vvvpll =vector<vvpll>; using vvvtll =vector<vvtll>;
using vvvvll=vector<vvvll>;using vvvvdd=vector<vvvdd>;using vvvvpll=vector<vvvpll>;using vvvvtll=vector<vvvtll>;

constexpr ll INF = 1LL << 60;
constexpr dd EPS = 1e-11;

//cin,cout高速化のおまじない＋桁数指定
struct Fast{
	Fast(){
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast;

#define REPS(i, S, E) for (ll i = (S); i <= (E); i++)
#define rep(i, S, E) REPS(i, S, E)
#define REP(i, N) REPS(i, 0, (N)-1)
#define DEPS(i, S, E) for (ll i = (E); i >= (S); i--)
#define dep(i, E, S) DEPS(i, S, E)
#define DEP(i, N) DEPS(i, 0, (N)-1)
#define EACH(e, v) for (auto&& e : v)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }
template<class T> inline T MaxE(vector<T>&v,ll S,ll E){T m=v[S]; REPS(i,S,E)chmax(m,v[i]); return m;}//v[S]～v[E]の最大値
template<class T> inline T MinE(vector<T>&v,ll S,ll E){T m=v[S]; REPS(i,S,E)chmin(m,v[i]); return m;}//v[S]～v[E]の最小値
template<class T> inline T MaxE(vector<T> &v, ll N) { return MaxE(v, 0, N - 1); } //先頭N個中の最大値
template<class T> inline T MinE(vector<T> &v, ll N) { return MinE(v, 0, N - 1); }
template<class T> inline T MaxE(vector<T> &v) { return MaxE(v, (ll)v.size()); }
template<class T> inline T MinE(vector<T> &v) { return MinE(v, (ll)v.size()); }
template<class T> inline ll MaxI(vector<T>&v,ll S,ll E){ll m=S; REPS(i,S,E){if(v[i]>v[m])m=i;} return m;}
template<class T> inline ll MinI(vector<T>&v,ll S,ll E){ll m=S; REPS(i,S,E){if(v[i]<v[m])m=i;} return m;}
template<class T> inline ll MaxI(vector<T> &v, ll N) { return MaxI(v, 0, N - 1); }
template<class T> inline ll MinI(vector<T> &v, ll N) { return MinI(v, 0, N - 1); }
template<class T> inline ll MaxI(vector<T> &v) { return MaxI(v, (ll)v.size()); }
template<class T> inline ll MinI(vector<T> &v) { return MinI(v, (ll)v.size()); }
template<class T> inline T Sum(vector<T> &v, ll S,ll E){ T s=v[S]; REPS(i,S+1,E)s+=v[i]; return s; }
template<class T> inline T Sum(vector<T> &v, ll N) { return Sum(v, 0, N - 1); }
template<class T> inline T Sum(vector<T> &v) { return Sum(v, v.size()); }
template<class T> inline ll Size(T &v){ return (ll)v.size(); }
template<class T> inline T POW(T a, ll n){ T r=1; for (; n>0; n>>=1, a*=a){ if (n&1)r*=a; } return r; }
inline ll POW(int a, ll n){ return POW((ll)a, n); }
inline ll MSB(ll a){for(ll o=63,x=-1;;){ll m=(o+x)/2; if(a<(1LL<<m))o=m; else x=m; if(o-x==1)return x;}}
inline ll CEIL(ll a, ll b){ return (a+b-1)/b; }
ll Gcd(ll a, ll b){ return (b==0) ? a : Gcd(b, a%b); }
ll Lcm(ll a, ll b){ return a * b / Gcd(a, b); }
inline vll Bit2Idx(ll m){vll v; for(ll i=0;m;m>>=1,i++) if(m&1)v.push_back(i); return move(v);}
inline ll BitNum(ll m){ for (ll c=0;; m>>=1){ c+=m&1; if (!m)return c; } }
inline ll Bit(ll s, ll i){ return (s>>i)&1; } //sの第ibit i=0-63
inline ll BitOn(ll s, ll i){ return s|(1LL<<i); } //sの第ibitON i=0-63
inline ll BitOff(ll s, ll i){ return s&~(1LL<<i); } //sの第ibitOFF i=0-63
template<class T> inline ll UnderNumOf(vector<T> &v, T x){ //sort済vのx以下の個数を得る
	return upper_bound(v.begin(), v.end(), x) - v.begin(); }
template<class T, class Pr> inline ll UnderNumOf(vector<T> &v, T x, Pr pred){ //x以下個数
	return upper_bound(v.begin(), v.end(), x, pred) - v.begin(); }
template<class T> inline ll OverNumOf(vector<T> &v, T x){ //sort済vのx以上の個数を得る
	return (ll)v.size() - (lower_bound(v.begin(), v.end(), x) - v.begin()); }
template<class T, class Pr> inline ll OverNumOf(vector<T> &v, T x, Pr pred){ //x以上の個数
	return (ll)v.size() - (lower_bound(v.begin(), v.end(), x, pred) - v.begin()); }

template<class T=ll> inline vector<T> cinv(ll N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
template<class T=ll, class S=ll> inline vector<pair<T, S>> cinv2(ll N){
	vector<pair<T, S>> v(N); REP(i,N){cin>>v[i].first>>v[i].second;} return move(v); }
template<class T=ll,class S=ll,class R=ll> inline vector<tuple<T, S, R>> cinv3(ll N){
	vector<tuple<T,S,R>> v(N); REP(i,N){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);} return move(v);}
template<class T=ll,class S=ll,class R=ll,class Q=ll> inline vector<tuple<T,S,R,Q>> cinv4(ll N){
	vector<tuple<T,S,R,Q>> v(N); REP(i,N){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i])>>get<3>(v[i]);} return move(v);}
template<class T=ll> inline vector<vector<T>> cinvv(ll N, ll M){
	vector<vector<T>> vv(N); REP(i, N) vv[i] = cinv(M); return move(vv);}
template<class T> inline void coutv(vector<T> &v, char deli=' '){
	ll N=(ll)v.size(); REP(i,N){cout << v[i] << ((i==N-1)?'\n':deli);} }
template<class T> void bye(T a){cout << a << '\n'; exit(0);}

#if defined(_DEBUG)
ll dumpW = 5;
template<class T> void Dump(vector<T> &v){
	REP(i, (ll)v.size()) { cerr << ((i==0)?"[":" ") << setw(dumpW) << v[i]; }  cerr << "]";
}
void Dump(vll &v){
	REP(i, (ll)v.size()) {
		cerr << ((i==0)?"[":" ") << setw(dumpW);
		if       (v[i] == INF) cerr << "INF";
		else if (v[i] == -INF) cerr << "-INF";
		else                   cerr << v[i];
	}  cerr << "]";
}
template<class T> void Dump(vector<vector<T>> &v){
	ll N=(ll)v.size();  string d[2][2]={{" ", "["},  {"\n", "]\n"}};
	REP(i, N) { cerr << d[0][i==0];  Dump(v[i]);  cerr << d[1][i==N-1]; }
}
template<class T> void Dump(vector<vector<vector<T>>> &v){
	ll N=(ll)v.size();  string d[2]={"  <", "[ <"};
	REP(i, N) { cerr << d[i==0] << i << ">\n"; Dump(v[i]); }  cerr << "]\n";
}
template<class T> void Dump(vector<vector<vector<vector<T>>>> &v){
	ll N=(ll)v.size();  string d[2]={"  ---<", "[ ---<"};
	REP(i, N) { cerr << d[i==0] << i << ">---\n"; Dump(v[i]); }  cerr << "]\n";
}
template<class T> void Dump(vector<vector<vector<vector<vector<T>>>>> &v){
	ll N=(ll)v.size();  string d[2]={"  ======<", "[ ======<"};
	REP(i, N) { cerr << d[i==0] << i << ">======\n"; Dump(v[i]); }  cerr << "]\n";
}
#else
template<class T> void Dump(vector<T> &v){}
template<class T> void Dump(vector<vector<T>> &v){}
template<class T> void Dump(vector<vector<vector<T>>> &v){}
template<class T> void Dump(vector<vector<vector<vector<T>>>> &v){}
template<class T> void Dump(vector<vector<vector<vector<vector<T>>>>> &v){}
#endif

template<ll MOD> struct mll_{
	ll val;
	mll_(ll v = 0): val(v % MOD){ if (val < 0) val += MOD; }
	mll_ operator - () const { return -val; }
	mll_ operator + (const mll_ &b) const { return val + b.val; }
	mll_ operator - (const mll_ &b) const { return val - b.val; }
	mll_ operator * (const mll_ &b) const { return val * b.val; }
	mll_ operator / (const mll_ &b) const { return mll_(*this) /= b; }
	mll_ operator + (ll b) const { return *this + mll_(b); }
	mll_ operator - (ll b) const { return *this - mll_(b); }
	mll_ operator * (ll b) const { return *this * mll_(b); }
	friend mll_ operator + (ll a, const mll_ &b) { return b + a; }
	friend mll_ operator - (ll a, const mll_ &b) { return -b + a; }
	friend mll_ operator * (ll a, const mll_ &b) { return b * a; }
	friend mll_ operator / (ll a, const mll_ &b) { return mll_(a)/b; }
	mll_ &operator += (const mll_ &b) { val=(val+b.val)%MOD; return *this; }
	mll_ &operator -= (const mll_ &b) { val=(val+MOD-b.val)%MOD; return *this; }
	mll_ &operator *= (const mll_ &b) { val=(val*b.val)%MOD; return *this; }
	mll_ &operator /= (const mll_ &b) {
		ll c=b.val, d=MOD, u=1, v=0;
		while (d){
			ll t = c / d;
			c -= t * d; swap(c, d);
			u -= t * v; swap(u, v);
		}
		val = val * u % MOD;
		if (val < 0) val += MOD;
		return *this;
	}
	mll_ &operator += (ll b) { return *this += mll_(b); }
	mll_ &operator -= (ll b) { return *this -= mll_(b); }
	mll_ &operator *= (ll b) { return *this *= mll_(b); }
	mll_ &operator /= (ll b) { return *this /= mll_(b); }
	bool operator == (const mll_ &b) { return val == b.val; }
	bool operator != (const mll_ &b) { return val != b.val; }
	bool operator == (ll b) { return *this == mll_(b); }
	bool operator != (ll b) { return *this != mll_(b); }
	friend bool operator == (ll a, const mll_ &b) { return mll_(a) == b.val; }
	friend bool operator != (ll a, const mll_ &b) { return mll_(a) != b.val; }
	friend ostream &operator << (ostream &os, const mll_ &a) { return os << a.val; }
	friend istream &operator >> (istream &is, mll_ &a) { return is >> a.val; }
	static mll_ Combination(ll a, ll b){
		chmin(b, a-b);
		if (b<0) return mll_(0);
		mll_ c = 1;
		REP(i, b) c *= a-i;
		REP(i, b) c /= i+1;
		return c;
	}
};
using mll = mll_<1000000007LL>; //1000000007LL;// 998244353LL;
using vmll = std::vector<mll>;
using vvmll = std::vector<vmll>;
using vvvmll = std::vector<vvmll>;
using vvvvmll = std::vector<vvvmll>;
using vvvvvmll = std::vector<vvvvmll>;

template<class T> struct SegmentTree{
	using F = function<T(T, T)>;
	vector<T> dat; //第i要素 dat[i+n-1]
	ll n; //要素数以上の最小の 2のべき乗
	F f;
	T ti;
	SegmentTree(){}
	SegmentTree(vector<T> &v, F f, T ti){ Init(v, f, ti); }
	void Init(vector<T> &v, F f, T ti){
		this->f=f; this->ti=ti;
		for (n = 1; n < (ll)v.size(); n *= 2);
		dat.resize(2*n-1, ti);
		REP(i, (ll)v.size()) { dat[i+n-1] = v[i]; }//初期化
		DEP(i, n-1) { dat[i] = f(dat[2*i+1], dat[2*i+2]); }//構築
	}
	void Set(ll i, T x){ //第i要素にxをセット
		i += n-1;  dat[i] = x;
		while (i>0) { i=(i-1)/2; dat[i]=f(dat[2*i+1], dat[2*i+2]); }
	}
	T Range(ll a, ll b) { return range(a, b, 0, 0, n); }
	T operator [] (ll i) { return dat[i+n-1]; }
	void Dump(ll w=5){
		REP(i, n) for (ll k=i+n-1, m=1, p=1; k>=0; p=m, m*=k%2, k=(k==0)?-1:(k-1)/2){
			if (m) cerr << ((k<n-1)?" ┬ ":"") << setw(w) << dat[k];
			else   cerr << ((p&~m) ?" ┘ ":"");
			if (k==0) cerr << '\n';
		} cerr << '\n';
	}
	T range(ll a, ll b, ll k, ll l, ll r){ //注目ノードk=[l,r)
		if (r<=a || b<=l) return ti; //完全に外
		if (a<=l && r<=b) return dat[k];//完全に含まれる
		return f(range(a, b, k*2+1, l, (l+r)/2), range(a, b, k*2+2, (l+r)/2, r));
	}
};

void solve()
{
	ll n;  cin >> n;
	vector<ll> P = cinv<ll>(n);
	vll loc(n+1);//loc[a] 数値aのあるidx
	rep(i, 0, n-1){
		loc[P[i]] = i;
	}
	vll ans;
	ans.push_back(0);

	set<ll> buf;
	buf.insert(loc[1]);
	ll x = 0;
	ll y = 0;
	auto it = buf.begin();
	vll ini(n, 0);
	ini[loc[1]]=1;
	SegmentTree<ll> sgt(
		ini,
		[](ll x, ll y){return x+y;}, //データ同士の合成関数
		0 //単位元
	);

	ll T = 0;
	ll S = 0;
	rep(k, 1, n-1){
		ll p = loc[k+1];
		//Tの更新
		if (k%2==0){ //k偶数
			auto iit = it;
			iit++;
			//中央より左の時
			if (p < *it){
				ll inter = *it - p - 1;
				inter -= sgt.Range(p+1, (*it));
				T += inter;
				T -= sgt.Range(0,p);//pの分減らす
			}
			//中央+1より右の時
			else if (*iit < p){
				ll inter = p - *iit - 1;
				inter -= sgt.Range((*iit)+1, p);
				T += inter;
				T -= sgt.Range(p+1,n);//pの分減らす
			}
			//中央の時
			else{
				T -= sgt.Range(p+1, n);//pの分減らす
			}
		}
		else{//奇数
			//中央より左の時
			if (p < *it){
				ll inter = *it - p - 1;
				inter -= sgt.Range(p+1, (*it));
				T += inter;
				T -= sgt.Range(0, p);//pの分減らす
			}
			//中央より右の時
			else{
				ll inter = p - *it - 1;
				inter -= sgt.Range((*it)+1, p);
				T += inter;
				T -= sgt.Range(p+1, n);//pの分減らす
			}
		}

		//1～kのswap数Sの更新
		S += sgt.Range(p+1, n);

		ans.push_back(T+S);

		//中央を保持するsetの操作
		if (p < *it) x++;
		else         y++;
		buf.insert(p);
		if (x-1 == y){
			it--; x--; y++;
		}
		else if (x+2 == y){
			it++; x++; y--;
		}

		//セグ木更新
		sgt.Set(p, 1);
	}

	coutv(ans);
}

int main(){
	solve();
	return 0;
}


#include "bits/stdc++.h"
#include <random>
using namespace std;
using ll    =long long;    using dd   =double;        using pll    =pair<ll, ll>;  using tll    =tuple<ll,ll,ll>;
using vll   =vector<ll>;   using vdd  =vector<dd>;    using vpll   =vector<pll>;   using vtll   =vector<tll>;
using vvll  =vector<vll>;  using vvdd =vector<vdd>;   using vvpll  =vector<vpll>;  using vvtll  =vector<vtll>;
using vvvll =vector<vvll>; using vvvdd=vector<vvdd>;  using vvvpll =vector<vvpll>; using vvvtll =vector<vvtll>;
using vvvvll=vector<vvvll>;using vvvvdd=vector<vvvdd>;using vvvvpll=vector<vvvpll>;using vvvvtll=vector<vvvtll>;

constexpr ll INF = 1LL << 60;
constexpr dd EPS = 1e-11;

//cin,cout高速化のおまじない＋桁数指定
struct Fast{
	Fast(){
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast;

#define REPS(i, S, E) for (ll i = (S); i <= (E); i++)
#define rep(i, S, E) REPS(i, S, E)
#define REP(i, N) REPS(i, 0, (N)-1)
#define DEPS(i, S, E) for (ll i = (E); i >= (S); i--)
#define dep(i, E, S) DEPS(i, S, E)
#define DEP(i, N) DEPS(i, 0, (N)-1)
#define EACH(e, v) for (auto&& e : v)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }
template<class T> inline T MaxE(vector<T>&v,ll S,ll E){T m=v[S]; REPS(i,S,E)chmax(m,v[i]); return m;}//v[S]～v[E]の最大値
template<class T> inline T MinE(vector<T>&v,ll S,ll E){T m=v[S]; REPS(i,S,E)chmin(m,v[i]); return m;}//v[S]～v[E]の最小値
template<class T> inline T MaxE(vector<T> &v, ll N) { return MaxE(v, 0, N - 1); } //先頭N個中の最大値
template<class T> inline T MinE(vector<T> &v, ll N) { return MinE(v, 0, N - 1); }
template<class T> inline T MaxE(vector<T> &v) { return MaxE(v, (ll)v.size()); }
template<class T> inline T MinE(vector<T> &v) { return MinE(v, (ll)v.size()); }
template<class T> inline ll MaxI(vector<T>&v,ll S,ll E){ll m=S; REPS(i,S,E){if(v[i]>v[m])m=i;} return m;}
template<class T> inline ll MinI(vector<T>&v,ll S,ll E){ll m=S; REPS(i,S,E){if(v[i]<v[m])m=i;} return m;}
template<class T> inline ll MaxI(vector<T> &v, ll N) { return MaxI(v, 0, N - 1); }
template<class T> inline ll MinI(vector<T> &v, ll N) { return MinI(v, 0, N - 1); }
template<class T> inline ll MaxI(vector<T> &v) { return MaxI(v, (ll)v.size()); }
template<class T> inline ll MinI(vector<T> &v) { return MinI(v, (ll)v.size()); }
template<class T> inline T Sum(vector<T> &v, ll S,ll E){ T s=v[S]; REPS(i,S+1,E)s+=v[i]; return s; }
template<class T> inline T Sum(vector<T> &v, ll N) { return Sum(v, 0, N - 1); }
template<class T> inline T Sum(vector<T> &v) { return Sum(v, v.size()); }
template<class T> inline ll Size(T &v){ return (ll)v.size(); }
template<class T> inline T POW(T a, ll n){ T r=1; for (; n>0; n>>=1, a*=a){ if (n&1)r*=a; } return r; }
inline ll POW(int a, ll n){ return POW((ll)a, n); }
inline ll MSB(ll a){for(ll o=63,x=-1;;){ll m=(o+x)/2; if(a<(1LL<<m))o=m; else x=m; if(o-x==1)return x;}}
inline ll CEIL(ll a, ll b){ return (a+b-1)/b; }
ll Gcd(ll a, ll b){ return (b==0) ? a : Gcd(b, a%b); }
ll Lcm(ll a, ll b){ return a * b / Gcd(a, b); }
inline vll Bit2Idx(ll m){vll v; for(ll i=0;m;m>>=1,i++) if(m&1)v.push_back(i); return move(v);}
inline ll BitNum(ll m){ for (ll c=0;; m>>=1){ c+=m&1; if (!m)return c; } }
inline ll Bit(ll s, ll i){ return (s>>i)&1; } //sの第ibit i=0-63
inline ll BitOn(ll s, ll i){ return s|(1LL<<i); } //sの第ibitON i=0-63
inline ll BitOff(ll s, ll i){ return s&~(1LL<<i); } //sの第ibitOFF i=0-63
template<class T> inline ll UnderNumOf(vector<T> &v, T x){ //sort済vのx以下の個数を得る
	return upper_bound(v.begin(), v.end(), x) - v.begin(); }
template<class T, class Pr> inline ll UnderNumOf(vector<T> &v, T x, Pr pred){ //x以下個数
	return upper_bound(v.begin(), v.end(), x, pred) - v.begin(); }
template<class T> inline ll OverNumOf(vector<T> &v, T x){ //sort済vのx以上の個数を得る
	return (ll)v.size() - (lower_bound(v.begin(), v.end(), x) - v.begin()); }
template<class T, class Pr> inline ll OverNumOf(vector<T> &v, T x, Pr pred){ //x以上の個数
	return (ll)v.size() - (lower_bound(v.begin(), v.end(), x, pred) - v.begin()); }

template<class T=ll> inline vector<T> cinv(ll N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
template<class T=ll, class S=ll> inline vector<pair<T, S>> cinv2(ll N){
	vector<pair<T, S>> v(N); REP(i,N){cin>>v[i].first>>v[i].second;} return move(v); }
template<class T=ll,class S=ll,class R=ll> inline vector<tuple<T, S, R>> cinv3(ll N){
	vector<tuple<T,S,R>> v(N); REP(i,N){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);} return move(v);}
template<class T=ll,class S=ll,class R=ll,class Q=ll> inline vector<tuple<T,S,R,Q>> cinv4(ll N){
	vector<tuple<T,S,R,Q>> v(N); REP(i,N){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i])>>get<3>(v[i]);} return move(v);}
template<class T=ll> inline vector<vector<T>> cinvv(ll N, ll M){
	vector<vector<T>> vv(N); REP(i, N) vv[i] = cinv(M); return move(vv);}
template<class T> inline void coutv(vector<T> &v, char deli=' '){
	ll N=(ll)v.size(); REP(i,N){cout << v[i] << ((i==N-1)?'\n':deli);} }
template<class T> void bye(T a){cout << a << '\n'; exit(0);}

#if defined(_DEBUG)
ll dumpW = 5;
template<class T> void Dump(vector<T> &v){
	REP(i, (ll)v.size()) { cerr << ((i==0)?"[":" ") << setw(dumpW) << v[i]; }  cerr << "]";
}
void Dump(vll &v){
	REP(i, (ll)v.size()) {
		cerr << ((i==0)?"[":" ") << setw(dumpW);
		if       (v[i] == INF) cerr << "INF";
		else if (v[i] == -INF) cerr << "-INF";
		else                   cerr << v[i];
	}  cerr << "]";
}
template<class T> void Dump(vector<vector<T>> &v){
	ll N=(ll)v.size();  string d[2][2]={{" ", "["},  {"\n", "]\n"}};
	REP(i, N) { cerr << d[0][i==0];  Dump(v[i]);  cerr << d[1][i==N-1]; }
}
template<class T> void Dump(vector<vector<vector<T>>> &v){
	ll N=(ll)v.size();  string d[2]={"  <", "[ <"};
	REP(i, N) { cerr << d[i==0] << i << ">\n"; Dump(v[i]); }  cerr << "]\n";
}
template<class T> void Dump(vector<vector<vector<vector<T>>>> &v){
	ll N=(ll)v.size();  string d[2]={"  ---<", "[ ---<"};
	REP(i, N) { cerr << d[i==0] << i << ">---\n"; Dump(v[i]); }  cerr << "]\n";
}
template<class T> void Dump(vector<vector<vector<vector<vector<T>>>>> &v){
	ll N=(ll)v.size();  string d[2]={"  ======<", "[ ======<"};
	REP(i, N) { cerr << d[i==0] << i << ">======\n"; Dump(v[i]); }  cerr << "]\n";
}
#else
template<class T> void Dump(vector<T> &v){}
template<class T> void Dump(vector<vector<T>> &v){}
template<class T> void Dump(vector<vector<vector<T>>> &v){}
template<class T> void Dump(vector<vector<vector<vector<T>>>> &v){}
template<class T> void Dump(vector<vector<vector<vector<vector<T>>>>> &v){}
#endif

template<ll MOD> struct mll_{
	ll val;
	mll_(ll v = 0): val(v % MOD){ if (val < 0) val += MOD; }
	mll_ operator - () const { return -val; }
	mll_ operator + (const mll_ &b) const { return val + b.val; }
	mll_ operator - (const mll_ &b) const { return val - b.val; }
	mll_ operator * (const mll_ &b) const { return val * b.val; }
	mll_ operator / (const mll_ &b) const { return mll_(*this) /= b; }
	mll_ operator + (ll b) const { return *this + mll_(b); }
	mll_ operator - (ll b) const { return *this - mll_(b); }
	mll_ operator * (ll b) const { return *this * mll_(b); }
	friend mll_ operator + (ll a, const mll_ &b) { return b + a; }
	friend mll_ operator - (ll a, const mll_ &b) { return -b + a; }
	friend mll_ operator * (ll a, const mll_ &b) { return b * a; }
	friend mll_ operator / (ll a, const mll_ &b) { return mll_(a)/b; }
	mll_ &operator += (const mll_ &b) { val=(val+b.val)%MOD; return *this; }
	mll_ &operator -= (const mll_ &b) { val=(val+MOD-b.val)%MOD; return *this; }
	mll_ &operator *= (const mll_ &b) { val=(val*b.val)%MOD; return *this; }
	mll_ &operator /= (const mll_ &b) {
		ll c=b.val, d=MOD, u=1, v=0;
		while (d){
			ll t = c / d;
			c -= t * d; swap(c, d);
			u -= t * v; swap(u, v);
		}
		val = val * u % MOD;
		if (val < 0) val += MOD;
		return *this;
	}
	mll_ &operator += (ll b) { return *this += mll_(b); }
	mll_ &operator -= (ll b) { return *this -= mll_(b); }
	mll_ &operator *= (ll b) { return *this *= mll_(b); }
	mll_ &operator /= (ll b) { return *this /= mll_(b); }
	bool operator == (const mll_ &b) { return val == b.val; }
	bool operator != (const mll_ &b) { return val != b.val; }
	bool operator == (ll b) { return *this == mll_(b); }
	bool operator != (ll b) { return *this != mll_(b); }
	friend bool operator == (ll a, const mll_ &b) { return mll_(a) == b.val; }
	friend bool operator != (ll a, const mll_ &b) { return mll_(a) != b.val; }
	friend ostream &operator << (ostream &os, const mll_ &a) { return os << a.val; }
	friend istream &operator >> (istream &is, mll_ &a) { return is >> a.val; }
	static mll_ Combination(ll a, ll b){
		chmin(b, a-b);
		if (b<0) return mll_(0);
		mll_ c = 1;
		REP(i, b) c *= a-i;
		REP(i, b) c /= i+1;
		return c;
	}
};
using mll = mll_<1000000007LL>; //1000000007LL;// 998244353LL;
using vmll = std::vector<mll>;
using vvmll = std::vector<vmll>;
using vvvmll = std::vector<vvmll>;
using vvvvmll = std::vector<vvvmll>;
using vvvvvmll = std::vector<vvvvmll>;

template<class T> struct SegmentTree{
	using F = function<T(T, T)>;
	vector<T> dat; //第i要素 dat[i+n-1]
	ll n; //要素数以上の最小の 2のべき乗
	F f;
	T ti;
	SegmentTree(){}
	SegmentTree(vector<T> &v, F f, T ti){ Init(v, f, ti); }
	void Init(vector<T> &v, F f, T ti){
		this->f=f; this->ti=ti;
		for (n = 1; n < (ll)v.size(); n *= 2);
		dat.resize(2*n-1, ti);
		REP(i, (ll)v.size()) { dat[i+n-1] = v[i]; }//初期化
		DEP(i, n-1) { dat[i] = f(dat[2*i+1], dat[2*i+2]); }//構築
	}
	void Set(ll i, T x){ //第i要素にxをセット
		i += n-1;  dat[i] = x;
		while (i>0) { i=(i-1)/2; dat[i]=f(dat[2*i+1], dat[2*i+2]); }
	}
	T Range(ll a, ll b) { return range(a, b, 0, 0, n); }
	T operator [] (ll i) { return dat[i+n-1]; }
	void Dump(ll w=5){
		REP(i, n) for (ll k=i+n-1, m=1, p=1; k>=0; p=m, m*=k%2, k=(k==0)?-1:(k-1)/2){
			if (m) cerr << ((k<n-1)?" ┬ ":"") << setw(w) << dat[k];
			else   cerr << ((p&~m) ?" ┘ ":"");
			if (k==0) cerr << '\n';
		} cerr << '\n';
	}
	T range(ll a, ll b, ll k, ll l, ll r){ //注目ノードk=[l,r)
		if (r<=a || b<=l) return ti; //完全に外
		if (a<=l && r<=b) return dat[k];//完全に含まれる
		return f(range(a, b, k*2+1, l, (l+r)/2), range(a, b, k*2+2, (l+r)/2, r));
	}
};

void solve()
{
	ll n;  cin >> n;
	vector<ll> P = cinv<ll>(n);
	vll loc(n+1);//loc[a] 数値aのあるidx
	rep(i, 0, n-1){
		loc[P[i]] = i;
	}
	vll ans;
	ans.push_back(0);

	set<ll> buf;
	buf.insert(loc[1]);
	ll x = 0;
	ll y = 0;
	auto it = buf.begin();
	vll ini(n, 0);
	ini[loc[1]]=1;
	SegmentTree<ll> sgt(
		ini,
		[](ll x, ll y){return x+y;}, //データ同士の合成関数
		0 //単位元
	);

	ll T = 0;
	ll S = 0;
	rep(k, 1, n-1){
		ll p = loc[k+1];
		//Tの更新
		if (k%2==0){ //k偶数
			auto iit = it;
			iit++;
			//中央より左の時
			if (p < *it){
				ll inter = *it - p - 1;
				inter -= sgt.Range(p+1, (*it));
				T += inter;
				T -= sgt.Range(0,p);//pの分減らす
			}
			//中央+1より右の時
			else if (*iit < p){
				ll inter = p - *iit - 1;
				inter -= sgt.Range((*iit)+1, p);
				T += inter;
				T -= sgt.Range(p+1,n);//pの分減らす
			}
			else{}
		}
		else{//奇数
			//中央より左の時
			if (p < *it){
				ll inter = *it - p - 1;
				inter -= sgt.Range(p+1, (*it));
				T += inter;
				T -= sgt.Range(0, p);//pの分減らす
			}
			//中央より右の時
			else{
				ll inter = p - *it - 1;
				inter -= sgt.Range((*it)+1, p);
				T += inter;
				T -= sgt.Range(p+1, n);//pの分減らす
			}
		}

		//1～kのswap数Sの更新
		S += sgt.Range(p+1, n);

		ans.push_back(T+S);

		//中央を保持するsetの操作
		if (p < *it) x++;
		else         y++;
		buf.insert(p);
		if (x-1 == y){
			it--; x--; y++;
		}
		else if (x+2 == y){
			it++; x++; y--;
		}

		//セグ木更新
		sgt.Set(p, 1);
	}

	coutv(ans);
}

int main(){
	solve();
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  gfg
int getSum(int BITree[], int index)
{
    int sum = 0;

    while (index > 0)
    {
        sum += BITree[index];

        // Move index to parent node in getSum View
        index -= index & (-index);
    }
    return sum;
}

// Updates a node in Binary Index Tree (BITree) at given index
// in BITree.  The given value 'val' is added to BITree[i] and
// all of its ancestors in tree.
void updateBIT(int BITree[], int n, int index, int val)
{
    // Traverse all ancestors and add 'val'
    while (index <= n)
    {
       // Add 'val' to current node of BI Tree
       BITree[index] += val;

       // Update index to that of parent in update View
       index += index & (-index);
    }
}

// Returns inversion count arr[0..n-1]
void getInvCount(int arr[], int n)
{
    int invcount = 0; // Initialize result

    // Find maximum element in arr[]
    int maxElement = 0;
    for (int i=0; i<n; i++)
        if (maxElement < arr[i])
            maxElement = arr[i];

    // Create a BIT with size equal to maxElement+1 (Extra
    // one is used so that elements can be directly be
    // used as index)
    int BIT[maxElement+1];
    for (int i=1; i<=maxElement; i++)
        BIT[i] = 0;

    // Traverse all elements from right.
    for (int i=n-1; i>=0; i--)
    {
        // Get count of elements smaller than arr[i]
        invcount += getSum(BIT, arr[i]-1);
        cout << invcount << " ";
        // Add current element to BIT
        updateBIT(BIT, maxElement, arr[i], 1);
    }
    return;
}

int32_t main()
{
    fastio;
    int n;
    cin >> n;
    int arr[n];
    for(int i=0;i<n;i++) cin >> arr[i];
    getInvCount(arr, n);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const double PI = 3.141592653589;
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
//#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set =  tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
     find_by_order(k): returns iterator to kth largest element (counting from 0)
     order_of_key (k): returns number of items which are strictly less than k
     remove #define int long long from template
*/

ordered_set<int> os;
// cp-algorithms
struct FenwickTree {
    vector<ll> bit;  // binary indexed tree
    int n;

    FenwickTree(int n) {
        this->n = n;
        bit.assign(n, 0);
    }

    FenwickTree(vector<int> a) : FenwickTree(a.size()) {
        for (size_t i = 0; i < a.size(); i++)
            add(i, a[i]);
    }

    ll sum(int r) {
        ll ret = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            ret += bit[r];
        return ret;
    }

    ll sum(int l, int r) {
        return sum(r) - sum(l - 1);
    }

    void add(int idx, int delta) {
        for (; idx < n; idx = idx | (idx + 1))
            bit[idx] += delta;
    }
};

int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n;
    cin >> n;
    vector<int> a(n);
    FenwickTree ft(n+1);
    map<int, int> m;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        m[a[i]] = i;
    }
    ll curr_inversion = 0;
    for(int i=1;i<=n;i++)
    {
        curr_inversion += (int)os.size() - os.order_of_key(m[i]);
        //pr(curr_inversion);
        ft.add(m[i], m[i]);
        os.insert(m[i]);
        if(i%2)
        {
            ll median = *os.find_by_order(i/2);
            ll z = i/2;
            ll lsum = median*z - ft.sum(median-1) - (z*(z+1))/2;
            ll rsum = ft.sum(median+1, n-1) - median*z - (z*(z+1))/2;
            //pr(lsum, rsum, curr_inversion, median);
            cout << curr_inversion + lsum + rsum << " ";
        }
        else
        {
            ll m1 = *os.find_by_order(i/2), m2 = *os.find_by_order((i-1)/2);
            ll curr_med = (m1 + m2)/2;
            ll additional = 0;
            if(curr_med != m2) additional = i/2;
            ll z = i/2;
            ll l = z;
            if(!additional) l--;
            ll lsum = curr_med*l - ft.sum(curr_med - 1) - (l*(l+1))/2;
            ll rsum = ft.sum(curr_med+1, n-1) - curr_med*z - (z*(z+1))/2;
            //pr(lsum, rsum, curr_inversion, curr_med, m1, m2, additional);
            cout << curr_inversion + lsum + rsum + additional << " ";
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
//#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set =  tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
     find_by_order(k): returns iterator to kth largest element (counting from 0)
     order_of_key (k): returns number of items which are strictly less than k
     remove #define int long long from template
*/

ordered_set<int> os;
// cp-algorithms
struct FenwickTree {
    vector<int> bit;  // binary indexed tree
    int n;

    FenwickTree(int n) {
        this->n = n;
        bit.assign(n, 0);
    }

    FenwickTree(vector<int> a) : FenwickTree(a.size()) {
        for (size_t i = 0; i < a.size(); i++)
            add(i, a[i]);
    }

    int sum(int r) {
        int ret = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            ret += bit[r];
        return ret;
    }

    int sum(int l, int r) {
        return sum(r) - sum(l - 1);
    }

    void add(int idx, int delta) {
        for (; idx < n; idx = idx | (idx + 1))
            bit[idx] += delta;
    }
};

int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n;
    cin >> n;
    vector<int> a(n);
    FenwickTree ft(n+1);
    map<int, int> m;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        m[a[i]] = i;
    }
    int curr_inversion = 0;
    for(int i=1;i<=n;i++)
    {
        curr_inversion += (int)os.size() - os.order_of_key(m[i]);
        //pr(curr_inversion);
        ft.add(m[i], m[i]);
        os.insert(m[i]);
        if(i%2)
        {
            int median = *os.find_by_order(i/2);
            int z = i/2;
            int lsum = median*z - ft.sum(median-1) - (z*(z+1))/2;
            int rsum = ft.sum(median+1, n-1) - median*z - (z*(z+1))/2;
            //pr(lsum, rsum, curr_inversion, median);
            cout << curr_inversion + lsum + rsum << " ";
        }
        else
        {
            int m1 = *os.find_by_order(i/2), m2 = *os.find_by_order((i-1)/2);
            int curr_med = (m1 + m2)/2;
            int additional = 0;
            if(curr_med != m2) additional = i/2;
            int z = i/2;
            int l = z;
            if(!additional) l--;
            int lsum = curr_med*l - ft.sum(curr_med - 1) - (l*(l+1))/2;
            int rsum = ft.sum(curr_med+1, n-1) - curr_med*z - (z*(z+1))/2;
            //pr(lsum, rsum, curr_inversion, curr_med, m1, m2, additional);
            cout << curr_inversion + lsum + rsum + additional << " ";
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
//#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set =  tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
     find_by_order(k): returns iterator to kth largest element (counting from 0)
     order_of_key (k): returns number of items which are strictly less than k
     remove #define int long long from template
*/

ordered_set<int> os;
// cp-algorithms
struct FenwickTree {
    vector<int> bit;  // binary indexed tree
    int n;

    FenwickTree(int n) {
        this->n = n;
        bit.assign(n, 0);
    }

    FenwickTree(vector<int> a) : FenwickTree(a.size()) {
        for (size_t i = 0; i < a.size(); i++)
            add(i, a[i]);
    }

    int sum(int r) {
        int ret = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            ret += bit[r];
        return ret;
    }

    int sum(int l, int r) {
        return sum(r) - sum(l - 1);
    }

    void add(int idx, int delta) {
        for (; idx < n; idx = idx | (idx + 1))
            bit[idx] += delta;
    }
};

int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n;
    cin >> n;
    vector<int> a(n);
    FenwickTree ft(n+1);
    map<int, int> m;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        m[a[i]] = i;
    }
    int curr_inversion = 0;
    for(int i=1;i<=n;i++)
    {
        curr_inversion += (int)os.size() - os.order_of_key(m[i]);
        //pr(curr_inversion);
        ft.add(m[i], m[i]);
        os.insert(m[i]);
        if(i%2)
        {
            int median = *os.find_by_order(i/2);
            int z = i/2;
            int lsum = median*z - ft.sum(median-1) - (z*(z+1))/2;
            int rsum = ft.sum(median+1, n-1) - median*z - (z*(z+1))/2;
            //pr(lsum, rsum, curr_inversion, median);
            cout << curr_inversion + lsum + rsum << " ";
        }
        else
        {
            int m1 = *os.find_by_order(i/2), m2 = *os.find_by_order((i-1)/2);
            int curr_med = (m1 + m2)/2;
            int additional = 0;
            if(curr_med != m2) additional = i/2;
            int z = i/2;
            int lsum = curr_med*(z-1) - ft.sum(curr_med - 1) - (z*(z-1))/2;
            int rsum = ft.sum(curr_med+1, n-1) - curr_med*z - (z*(z+1))/2;
            //pr(lsum, rsum, curr_inversion, curr_med, m1, m2, additional);
            cout << curr_inversion + lsum + rsum + additional << " ";
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const double PI = 3.141592653589;
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
//#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set =  tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
     find_by_order(k): returns iterator to kth largest element (counting from 0)
     order_of_key (k): returns number of items which are strictly less than k
     remove #define int long long from template
*/

ordered_set<int> os;
// cp-algorithms
struct FenwickTree {
    vector<int> bit;  // binary indexed tree
    int n;

    FenwickTree(int n) {
        this->n = n;
        bit.assign(n, 0);
    }

    FenwickTree(vector<int> a) : FenwickTree(a.size()) {
        for (size_t i = 0; i < a.size(); i++)
            add(i, a[i]);
    }

    ll sum(int r) {
        ll ret = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            ret += bit[r];
        return ret;
    }

    ll sum(int l, int r) {
        return sum(r) - sum(l - 1);
    }

    void add(int idx, int delta) {
        for (; idx < n; idx = idx | (idx + 1))
            bit[idx] += delta;
    }
};

int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n;
    cin >> n;
    vector<int> a(n);
    FenwickTree ft(n+1);
    map<int, int> m;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        m[a[i]] = i;
    }
    ll curr_inversion = 0;
    for(int i=1;i<=n;i++)
    {
        curr_inversion += (int)os.size() - os.order_of_key(m[i]);
        //pr(curr_inversion);
        ft.add(m[i], m[i]);
        os.insert(m[i]);
        if(i%2)
        {
            ll median = *os.find_by_order(i/2);
            ll z = i/2;
            ll lsum = median*z - ft.sum(median-1) - (z*(z+1))/2;
            ll rsum = ft.sum(median+1, n-1) - median*z - (z*(z+1))/2;
            //pr(lsum, rsum, curr_inversion, median);
            cout << curr_inversion + lsum + rsum << " ";
        }
        else
        {
            ll m1 = *os.find_by_order(i/2), m2 = *os.find_by_order((i-1)/2);
            ll curr_med = (m1 + m2)/2;
            ll additional = 0;
            if(curr_med != m2) additional = i/2;
            ll z = i/2;
            ll l = z;
            if(!additional) l--;
            ll lsum = curr_med*l - ft.sum(curr_med - 1) - (l*(l+1))/2;
            ll rsum = ft.sum(curr_med+1, n-1) - curr_med*z - (z*(z+1))/2;
            //pr(lsum, rsum, curr_inversion, curr_med, m1, m2, additional);
            cout << curr_inversion + lsum + rsum + additional << " ";
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const double PI = 3.141592653589;
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
//#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set =  tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
     find_by_order(k): returns iterator to kth largest element (counting from 0)
     order_of_key (k): returns number of items which are strictly less than k
     remove #define int long long from template
*/

ordered_set<int> os;
// cp-algorithms
struct FenwickTree {
    vector<int> bit;  // binary indexed tree
    int n;

    FenwickTree(int n) {
        this->n = n;
        bit.assign(n, 0);
    }

    FenwickTree(vector<int> a) : FenwickTree(a.size()) {
        for (size_t i = 0; i < a.size(); i++)
            add(i, a[i]);
    }

    int sum(int r) {
        int ret = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            ret += bit[r];
        return ret;
    }

    int sum(int l, int r) {
        return sum(r) - sum(l - 1);
    }

    void add(int idx, int delta) {
        for (; idx < n; idx = idx | (idx + 1))
            bit[idx] += delta;
    }
};

int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n;
    cin >> n;
    vector<int> a(n);
    FenwickTree ft(n+1);
    map<int, int> m;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        m[a[i]] = i;
    }
    ll curr_inversion = 0;
    for(int i=1;i<=n;i++)
    {
        curr_inversion += (int)os.size() - os.order_of_key(m[i]);
        //pr(curr_inversion);
        ft.add(m[i], m[i]);
        os.insert(m[i]);
        if(i%2)
        {
            ll median = *os.find_by_order(i/2);
            ll z = i/2;
            ll lsum = median*z - ft.sum(median-1) - (z*(z+1))/2;
            ll rsum = ft.sum(median+1, n-1) - median*z - (z*(z+1))/2;
            //pr(lsum, rsum, curr_inversion, median);
            cout << curr_inversion + lsum + rsum << " ";
        }
        else
        {
            ll m1 = *os.find_by_order(i/2), m2 = *os.find_by_order((i-1)/2);
            ll curr_med = (m1 + m2)/2;
            ll additional = 0;
            if(curr_med != m2) additional = i/2;
            ll z = i/2;
            ll l = z;
            if(!additional) l--;
            ll lsum = curr_med*l - ft.sum(curr_med - 1) - (l*(l+1))/2;
            ll rsum = ft.sum(curr_med+1, n-1) - curr_med*z - (z*(z+1))/2;
            //pr(lsum, rsum, curr_inversion, curr_med, m1, m2, additional);
            cout << curr_inversion + lsum + rsum + additional << " ";
        }
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 200000+10;

int n;
int a[maxn],c[maxn],p[maxn];
LL f[maxn],d[maxn];
priority_queue<int> h1;
priority_queue<int,vector<int>,greater<int> > h2;

inline int lowbit(int x)
{
    return x&(-x);
}

void add(int x)
{
    while (x<=n)
    {
        c[x]++;
        x+=lowbit(x);
    }
}

int ask(int x)
{
    int ans=0;
    while (x>0)
    {
        ans+=c[x];
        x-=lowbit(x);
    }
    return ans;
}

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]),p[a[i]]=i;
    add(p[1]); f[1]=0; d[1]=0;
    h2.push(p[1]);
    LL sum1=0;
    LL sum2=p[1];
    for (int i=2;i<=n;i++)
    {
        if (p[i]>h2.top())
        {
            h2.push(p[i]);
            sum2+=p[i];
            while (h1.size()<(i/2))
            {
                int tmp=h2.top();
                h2.pop();
                h1.push(tmp);
                sum2-=tmp;
                sum1+=tmp;
            }
        } else
        {
            h1.push(p[i]);
            sum1+=p[i];
            while (h1.size()>(i/2))
            {
                int tmp=h1.top();
                h1.pop();
                h2.push(tmp);
                sum1-=tmp;
                sum2+=tmp;
            }
        }
        //printf("%d\n",h2.top());
        LL mid=(LL)h2.top()-(LL)h1.size();
        LL sz1=h1.size();
        LL sz2=h2.size();
        //printf("%lld %lld %lld %lld %lld\n",mid,sz1,sz2,sum1,sum2);
        LL num1=mid*sz1-sum1+((sz1-1)*sz1)/2ll;
        LL num2=sum2-mid*sz2-(sz2*(sz2-1ll+2ll*sz1))/2ll;
        //printf("%lld %lld\n",num1,num2);
        d[i]=d[i-1]+ask(n)-ask(p[i]);
        f[i]=num1+num2+d[i];
        add(p[i]);
    }
    for (int i=1;i<=n;i++) printf("%lld%c",f[i],i==n?'\n':' ');
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#include <bits/extc++.h> /** keep-include */
using namespace __gnu_pbds;

template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){

}

void solve(){

}

const ll inf = 1e9;
struct Node {
	Node *l = 0, *r = 0;
	int lo, hi;
    ll val = 0;
	Node(int lo,int hi): lo(lo),hi(hi){} // Large interval of -inf
	Node(vi& v, int lo, int hi) : lo(lo), hi(hi) {
		if (lo + 1 < hi) {
			int mid = lo + (hi - lo)/2;
			l = new Node(v, lo, mid); r = new Node(v, mid, hi);
		}
	}
	ll query(int L, int R) {
		if (R <= lo || hi <= L) return 0;
		if (L <= lo && hi <= R) return val;
		return l->query(L, R)+r->query(L, R);
	}
	void add(int L, int R, ll x) {
		if (R <= lo || hi <= L) return;
		if (L <= lo && hi <= R) val = x;
		else {
			l->add(L, R, x), r->add(L, R, x);
			val = l->val+r->val;
		}
	}
};

ll C2(ll x){
    return x*(x+1)/2;
}
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    int n;cin>>n;
    vi p(n+1,0), pos(n+1,0);
    repA(i,1,n)cin>>p[i], pos[p[i]]=i;

    Tree<int > T;
    vi v;
    Node N(v,0,n+10);

    ll ans=0;
    repA(i,1,n){
        int j = pos[i];
        ans+=i-1-T.order_of_key(j);
        T.insert(j);
        N.add(j,j+1,j);

        ll m=*T.find_by_order(i/2);
        ll r=(i-1)/2, l=i/2;
        ll sr=N.query(m+1,n+1);
        ll sl=N.query(0,m);
        ll cur = sr-r*m-C2(r)+l*m-sl-C2(l)+ans;
        cout<<cur<<'\n';
    }

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#include <bits/extc++.h> /** keep-include */
using namespace __gnu_pbds;

template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){

}

void solve(){

}

const ll inf = 1e9;
struct Node {
	Node *l = 0, *r = 0;
	int lo, hi;
    ll val = 0;
	Node(int lo,int hi): lo(lo),hi(hi){} // Large interval of -inf
	Node(vi& v, int lo, int hi) : lo(lo), hi(hi) {
		if (lo + 1 < hi) {
			int mid = lo + (hi - lo)/2;
			l = new Node(v, lo, mid); r = new Node(v, mid, hi);
		}
	}
	ll query(int L, int R) {
		if (R <= lo || hi <= L) return 0;
		if (L <= lo && hi <= R) return val;
		return l->query(L, R)+r->query(L, R);
	}
	void add(int L, int R, ll x) {
		if (R <= lo || hi <= L) return;
		if (L <= lo && hi <= R) val = x;
		else {
			l->add(L, R, x), r->add(L, R, x);
			val = l->val+r->val;
		}
	}
};

ll C2(ll x){
    return x*(x+1)/2;
}
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    int n;cin>>n;
    vi p(n+1,0), pos(n+1,0);
    repA(i,1,n)cin>>p[i], pos[p[i]]=i;

    Tree<int > T;
    vi v;
    Node N(v,0,n+10);

    ll ans=0;
    repA(i,1,n){
        int j = pos[i];
        ans+=i-1-T.order_of_key(j);
        T.insert(j);
        N.add(j,j+1,j);

        int m=*T.find_by_order(i/2);
        int r=(i-1)/2, l=i/2;
        ll sr=N.query(m+1,n+1);
        ll sl=N.query(0,m);
        ll cur = sr-r*m-C2(r)+l*m-sl-C2(l)+ans;
        cout<<cur<<'\n';
    }

	return 0;
}


#include <bits/stdc++.h>

#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(int i=n;i<=N;++i)
#define rap(i,n,N) for(int i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define pllll pair<pll,pll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl '\n'
const int MAX = 3e5+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll MOD2 = 1000000006;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 316;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update> pbds;
pbds op;

ll n,x,z[MAX],bit[MAX],ans,pos,mid;

inline void upd(int i){
	for(; i<=n; i+=(i&-i))++bit[i];
	return;
}
int ret;
inline int que(int i){
	ret = 0;
	for(;i>0;i-=(i&-i))ret+=bit[i];
	return ret;
}

int main(){
//	cout<<fixed<<setprecision(2);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n;
    rep(i,1,n)cin>>x, z[x] = i;
    auto it = op.begin();
	rep(i,1,n){
		ans+=que(n-z[i]+1), upd(n-z[i]+1);
		pos = op.order_of_key(z[i]), mid = i>>1;
		ans-= min(pos,i-pos-1);
		if(i!=1 && (i&1)){
			if(pos<mid)ans+= *op.find_by_order(mid-1) - z[i] - (mid-pos);
			else if(pos>mid)ans+= z[i] - *op.find_by_order(mid) - (pos-mid);
		}
		else if(i!=1){
			if(pos<mid)ans+= *op.find_by_order(mid-1) - z[i] - (mid-pos);
			else ans+= z[i] - *op.find_by_order(mid-1) - (pos-mid+1);
		}
		op.insert(z[i]);
		cout<<ans<<' ';
	}
	cout<<endl;
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define isws std::ios::sync_with_stdio(false)
#define _USE_MATH_DEFINES
#define ll long long
#define ull unsigned long long

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <math.h>
#include <cmath>
#include <string>
#include <bitset>

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mt make_tuple
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef pair<int, int> PII;
const ll mod = 1000000007;

const int N = 200000 + 7;

int arr[N];
int pos[N];
int BIT[N];
int n;
ll uop[N];
ll BIT2[N];
ll fans[N];

int query(int idx) {
	int sum = 0;
	idx++;
	while (idx > 0) {
		sum += BIT[idx];
		idx -= idx & (-idx);
	}
	return sum;
}

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

ll query2(int idx) {
	ll sum = 0;
	idx++;
	while (idx > 0) {
		sum += BIT2[idx];
		idx -= idx & (-idx);
	}
	return sum;
}

void update2(int idx, ll val) {
	idx++;
	while (idx <= n) {
		BIT2[idx]+=val;
		idx += idx & (-idx);
	}
}

int bsearch(int x) {
	int ans = n + 1;
	int lo = 0, hi = n - 1;
	while (lo <= hi) {
		int mid = (lo + hi) / 2;
		int t = query(mid);
		if (t >= x) {
			ans = min(ans, mid);
			hi = mid - 1;
		}
		else {
			lo = mid + 1;
		}
	}
	return ans;
}

int main()
{
	isws;
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	ll T = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
		pos[arr[i]] = i;
	}
	for (int i = 1; i <= n; i++) {
		int x = query(pos[i]);
		uop[i] = ((ll)i - 1 - x);
		uop[i]+= uop[i - 1];
		update(pos[i]);
		update2(pos[i], pos[i]);
		T += pos[i];
		if (i % 2 == 1) {
			int search = (i + 1) / 2;
			int idx = bsearch(search);
			search--;
			ll v1 = query2(idx);
			ll v2 = T - v1;
			ll numSwap = ((ll)search + 1) * idx - v1 - ((ll)search * ((ll)search + 1)) + v2 - ((ll)search * idx);
			//cout << i << " " << uop[i] + numSwap << "\n";
			fans[i] = uop[i] + numSwap;
		}
		else {
			int search = i / 2;
			int idx1 = bsearch(search);
			search++;
			int idx2 = bsearch(search);
			int idx = (idx1 + idx2) / 2;
			ll v1 = query2(idx);
			ll v2 = T - v1;
			search--;
			ll numSwap = (ll)search * idx - v1 - ((ll)search * ((ll)search - 1)) / 2 + v2 - (ll)search * idx - ((ll)search * ((ll)search + 1)) / 2;
			//cout << i << " " << uop[i] + numSwap << "\n";
			fans[i] = uop[i] + numSwap;
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << fans[i] << " ";
	}
	cout << "\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX=3e5+5;
ll MOD=1e9+7;
#define pb push_back
#define se second
#define fi first
#define sb __builtin_popcount
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fbo find_by_order
#define ook order_of_key
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define pll pair<ll,ll>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
ll add(ll a,ll b){return (a+b)%MOD;}
ll mul(ll a,ll b){return (a*b)%MOD;}
ll sub(ll a,ll b){return (a-b+MOD)%MOD;}
#define boost               ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define error 0.000000000000000001
ll value[MAX],arr[MAX];
int main()
{
	ll n;
	cin>>n;
	ll pos1;
	for(ll i=1;i<=n;i++){cin>>arr[i];if(arr[i]==1)pos1=i;}
		ll pos=0;
	ordered_set s1;
	for(ll i=pos1-1;i>=1;i--){
		value[arr[i]]=arr[i]+s1.size()-s1.ook(arr[i])-1;
		s1.insert(arr[i]);
	}
	ordered_set s;
	ll ans=0;
	for(ll i=pos1+1;i<=n;i++){
		value[arr[i]]=s.size()-s.ook(arr[i]);
		s.insert(arr[i]);
	}
	for(ll i=1;i<=n;i++){ans+=value[i];cout<<ans<<' ';}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX=3e5+5;
ll MOD=1e9+7;
#define pb push_back
#define se second
#define fi first
#define sb __builtin_popcount
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fbo find_by_order
#define ook order_of_key
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define pll pair<ll,ll>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
ll add(ll a,ll b){return (a+b)%MOD;}
ll mul(ll a,ll b){return (a*b)%MOD;}
ll sub(ll a,ll b){return (a-b+MOD)%MOD;}
#define boost               ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define error 0.000000000000000001
ll arr[MAX],pos[MAX],inv[MAX];
int main()
{
	ll n;
	cin>>n;
	ordered_set s;
	for(ll i=1;i<=n;i++){
		cin>>arr[i];
		pos[arr[i]]=i;
	}
	for(ll i=n;i>=1;i--){
		s.insert(arr[i]);
		inv[arr[i]]=s.ook(arr[i]);
	}
	ll ans=0,ans1=0;
	s.clear();
	cout<<0<<' ';
	s.insert(pos[1]);
	//debug(inv[2]);
	for(ll i=2;i<=n;i++){
		//debug(inv[i]);
		ll curr;
		ans-=min(s.ook(pos[i]),s.size()-s.ook(pos[i]));
		if(i&1){
			ll  curr1=*(s.fbo(i/2-1)),curr2=*(s.fbo(i/2));
			if(pos[i]>curr2)curr=curr2;
			else if(pos[i]<curr1)curr=curr1;
			else curr=pos[i];
		}
		else
			curr=*(s.fbo(i/2-1));
		//if(i==2)debug2(pos[i],curr);
		s.insert(pos[i]);
		ll a=min(pos[i],curr);
		ll b=max(pos[i],curr);
		ll x=s.ook(b)-s.ook(a);
		ans+=b-a-x;
		ans1+=inv[i];
		cout<<ans+ans1<<' ';
	}
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
const long double M_PI = 3.14159265358979323846265;
const ll INF = 1LL << 30;//1^9
const ll INFL = 1LL << 60;//10^18 = 2^60
//ll MOD = 998244353;
void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}

const ll SIZE = 200010;
ll bit[SIZE];
void bit_add(ll i, ll x){//iは0-index
  i++;
  int cnt = 0;
  while(i < SIZE){
    bit[i] += x;
    i += i & -i;
  }
}

ll bit_sum(ll x){//xは0_index
  if(x < 0) return 0;
  x++;
  ll res = 0;
  while(x > 0){
    res += bit[x];
    x -= x & -x;
  }
  return res;
}

void bit_reset(){
  rep(i, SIZE) bit[i] = 0;
}

//区間加算区間和
const ll N_ = 1<<20;
ll seg[2][2 * N_ - 1], lazy[2][2 * N_ - 1];
ll m_seg[2 * N_ - 1];
void eval(ll id, ll k, ll l, ll r){
  if(lazy[id][k] == 0) return;
  seg[id][k] += lazy[id][k];
  if(r - l > 1){
    lazy[id][2 * k + 1] += lazy[id][k] / 2;
    lazy[id][2 * k + 2] += lazy[id][k] / 2;
  }
  lazy[id][k] = 0;
}

void add(ll id, ll a, ll b, ll x, ll k = 0, ll l = 0, ll r = N_){
  eval(id, k, l, r);
  if(r <= a || b <= l) return;
  if(a <= l && r <= b){
    lazy[id][k] += (r - l) * x;
    eval(id, k, l, r);
    return;
  }
  add(id, a, b, x, 2 * k + 1, l, (l + r) / 2);
  add(id, a, b, x, 2 * k + 2, (l + r) / 2, r);
  seg[id][k] = seg[id][2 * k + 1] + seg[id][2 * k + 2];
  return;
}

ll getsum(ll id, ll a, ll b, ll k = 0, ll l = 0, ll r = N_){
  if(r <= a || b <= l) return 0;
  eval(id, k, l, r);
  if(a <= l && r <= b) return seg[id][k];
  ll vl = getsum(id, a, b, 2 * k + 1, l, (l + r) / 2);
  ll vr = getsum(id, a, b, 2 * k + 2, (l + r) / 2, r);
  return vl + vr;
}

void solve(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N){
    cin >> A[i];
    A[i]--;
  }
  vector<ll> pos(N);
  rep(i, N) pos[A[i]] = i;
  vector<ll> f(N);
  ll sum = 0;
  rep(i, N){
    sum += i - bit_sum(pos[i]);
    bit_add(pos[i], 1);
    f[i] = sum;
  }

  bit_reset();
  set<ll> left, right;
  rep(i, N){
    bit_add(pos[i], 1);
    add(0, pos[i]+1, N_, 1);
    add(1, 0, pos[i], 1);
    if(right.size() == 0){
      right.insert(pos[i]);
    }else if(left.size() == right.size()){
      right.insert(pos[i]);
    }else{
      left.insert(pos[i]);
    }
    if(left.size()){
      ll l = *left.rbegin();
      ll r = *right.begin();
      left.erase(l);
      right.erase(r);
      left.insert(min(l, r));
      right.insert(max(l, r));
    }
    ll mid = *right.begin();
    f[i] += getsum(0, 0, mid) + getsum(1, mid+1, N_);
    ll delta = getsum(0, 0, mid) + getsum(1, mid+1, N_);
    ll l = bit_sum(mid-1);
    ll r = i - l;
    f[i] -= (l-1) * l / 2;
    f[i] -= (r-1) * r / 2;
  }

  rep(i, N){
    cout << f[i];
    if(i == N-1) cout << endl;
    else cout << " ";
  }
}

int main(){
  solve();
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
const long double M_PI = 3.14159265358979323846265;
const ll INFL = 1LL << 60;//10^18 = 2^60
//ll MOD = 998244353;
void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}

const ll SIZE = 200010;
ll bit[SIZE];
void bit_add(ll i, ll x){//iは0-index
  i++;
  int cnt = 0;
  while(i < SIZE){
    bit[i] += x;
    i += i & -i;
  }
}

ll bit_sum(ll x){//xは0_index
  if(x < 0) return 0;
  x++;
  ll res = 0;
  while(x > 0){
    res += bit[x];
    x -= x & -x;
  }
  return res;
}

void bit_reset(){
  rep(i, SIZE) bit[i] = 0;
}

void solve(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N){
    cin >> A[i];
    A[i]--;
  }
  vector<ll> pos(N);
  rep(i, N) pos[A[i]] = i;
  vector<ll> f(N);
  ll sum = 0;
  rep(i, N){
    sum += i - bit_sum(pos[i]);
    bit_add(pos[i], 1);
    f[i] = sum;
  }

  bit_reset();
  ll now = 0;
  ll mid = pos[0];
  bit_add(pos[0], 1);
  set<ll> left, right;
  ll leftSum = 0, rightSum = 0;
  for(ll i = 1; i < N; i++){
    bit_add(pos[i], 1);
    if(mid < pos[i]){
      //1 0 0 0 1 0 0 mid 0 0 new 0 0 1
      right.insert(pos[i]);
      rightSum -= bit_sum(SIZE-5) - bit_sum(pos[i]);
      rightSum += pos[i] - mid - 1 - (bit_sum(pos[i]-1) - bit_sum(mid));
    }else{
      //1 0 0 0 1 0 0 new 0 0 mid 0 0 1
      left.insert(pos[i]);
      leftSum -= bit_sum(pos[i]-1);
      leftSum += mid - pos[i] - 1 - (bit_sum(mid-1) - bit_sum(pos[i]));
    }
    now = leftSum + rightSum;

    while(true){
      ll LL, LR, RL, RR;
      if(right.size() == 0){//右に移動した時
        RL = INFL;
        RR = INFL;
      }else{
        RL = leftSum + (*right.begin() - mid - 1) * (left.size() + 1);
        RR = rightSum - (*right.begin() - mid - 1) * right.size();
      }
      if(left.size() == 0){
        LL = INFL;
        LR = INFL;
      }else{
        LL = leftSum - (mid - *left.rbegin() - 1) * left.size();
        LR = rightSum + (mid - *left.rbegin() - 1) * (right.size() + 1);
      }
      if(now > RL + RR){
        now = RL + RR;
        leftSum = RL;
        rightSum = RR;
        left.insert(mid);
        mid = *right.begin();
        right.erase(mid);
      }else if(now > LL + LR){
        now = LL + LR;
        leftSum = LL;
        rightSum = LR;
        right.insert(mid);
        mid = *left.rbegin();
        left.erase(mid);
      }else{
        break;
      }
    }
    f[i] += now;
  }

  rep(i, N){
    cout << f[i];
    if(i == N-1) cout << endl;
    else cout << " ";
  }
}

int main(){
  solve();
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
const long double M_PI = 3.14159265358979323846265;
const ll INFL = 1LL << 60;//10^18 = 2^60
//ll MOD = 998244353;
void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}

const ll SIZE = 200010;
ll bit[SIZE];
void bit_add(ll i, ll x){//iは0-index
  i++;
  int cnt = 0;
  while(i < SIZE){
    bit[i] += x;
    i += i & -i;
  }
}

ll bit_sum(ll x){//xは0_index
  if(x < 0) return 0;
  x++;
  ll res = 0;
  while(x > 0){
    res += bit[x];
    x -= x & -x;
  }
  return res;
}

void bit_reset(){
  rep(i, SIZE) bit[i] = 0;
}

void solve(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N){
    cin >> A[i];
    A[i]--;
  }
  vector<ll> pos(N);
  rep(i, N) pos[A[i]] = i;
  vector<ll> f(N);
  ll sum = 0;
  rep(i, N){
    sum += i - bit_sum(pos[i]);
    bit_add(pos[i], 1);
    f[i] = sum;
  }

  bit_reset();
  ll now = 0;
  ll mid = pos[0];
  bit_add(pos[0], 1);
  set<ll> left, right;
  ll leftSum = 0, rightSum = 0;
  for(ll i = 1; i < N; i++){
    bit_add(pos[i], 1);
    if(mid < pos[i]){
      //1 0 0 0 1 0 0 mid 0 0 new 0 0 1
      right.insert(pos[i]);
      rightSum -= bit_sum(SIZE-5) - bit_sum(pos[i]);
      rightSum += pos[i] - mid - 1 - (bit_sum(pos[i]-1) - bit_sum(mid));
    }else{
      //1 0 0 0 1 0 0 new 0 0 mid 0 0 1
      left.insert(pos[i]);
      leftSum -= bit_sum(pos[i]-1);
      leftSum += mid - pos[i] - 1 - (bit_sum(mid-1) - bit_sum(pos[i]));
    }
    now = leftSum + rightSum;

    bool maxRight = 0;
    while(true){
      ll LL, LR, RL, RR;
      if(right.size() == 0){//右に移動した時
        RL = INFL;
        RR = INFL;
      }else{
        RL = leftSum + (*right.begin() - mid - 1) * (left.size() + 1);
        RR = rightSum - (*right.begin() - mid - 1) * right.size();
      }
      if(left.size() == 0){
        LL = INFL;
        LR = INFL;
      }else{
        LL = leftSum - (mid - *left.rbegin() - 1) * left.size();
        LR = rightSum + (mid - *left.rbegin() - 1) * (right.size() + 1);
      }
      if(now >= RL + RR && maxRight == 0){
        now = RL + RR;
        leftSum = RL;
        rightSum = RR;
        left.insert(mid);
        mid = *right.begin();
        right.erase(mid);
      }else if(now >= LL + LR){
        maxRight = 1;
        now = LL + LR;
        leftSum = LL;
        rightSum = LR;
        right.insert(mid);
        mid = *left.rbegin();
        left.erase(mid);
      }else{
        break;
      }
    }
    f[i] += now;
  }

  rep(i, N){
    cout << f[i];
    if(i == N-1) cout << endl;
    else cout << " ";
  }
}

int main(){
  solve();
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
const long double M_PI = 3.14159265358979323846265;
const ll INFL = 1LL << 60;//10^18 = 2^60
//ll MOD = 998244353;
void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}

const ll SIZE = 200010;
ll bit[SIZE];
void bit_add(ll i, ll x){//iは0-index
  i++;
  int cnt = 0;
  while(i < SIZE){
    bit[i] += x;
    i += i & -i;
  }
}

ll bit_sum(ll x){//xは0_index
  if(x < 0) return 0;
  x++;
  ll res = 0;
  while(x > 0){
    res += bit[x];
    x -= x & -x;
  }
  return res;
}

void bit_reset(){
  rep(i, SIZE) bit[i] = 0;
}

void solve(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N){
    cin >> A[i];
    A[i]--;
  }
  vector<ll> pos(N);
  rep(i, N) pos[A[i]] = i;
  vector<ll> f(N);
  ll sum = 0;
  rep(i, N){
    sum += i - bit_sum(pos[i]);
    bit_add(pos[i], 1);
    f[i] = sum;
  }

  bit_reset();
  ll now = 0;
  ll mid = pos[0];
  bit_add(pos[0], 1);
  set<ll> left, right;
  ll leftSum = 0, rightSum = 0;
  for(ll i = 1; i < N; i++){
    bit_add(pos[i], 1);
    if(mid < pos[i]){
      //1 0 0 0 1 0 0 mid 0 0 new 0 0 1
      right.insert(pos[i]);
      rightSum -= bit_sum(SIZE-5) - bit_sum(pos[i]);
      rightSum += pos[i] - mid - 1 - (bit_sum(pos[i]-1) - bit_sum(mid));
    }else{
      //1 0 0 0 1 0 0 new 0 0 mid 0 0 1
      left.insert(pos[i]);
      leftSum -= bit_sum(pos[i]-1);
      leftSum += mid - pos[i] - 1 - (bit_sum(mid-1) - bit_sum(pos[i]));
    }
    now = leftSum + rightSum;

    bool maxRight = 0;
    while(now){
      ll LL, LR, RL, RR;
      if(right.size() == 0){//右に移動した時
        RL = INFL;
        RR = INFL;
      }else{
        RL = leftSum + (*right.begin() - mid - 1) * (left.size() + 1);
        RR = rightSum - (*right.begin() - mid - 1) * right.size();
      }
      if(left.size() == 0){
        LL = INFL;
        LR = INFL;
      }else{
        LL = leftSum - (mid - *left.rbegin() - 1) * left.size();
        LR = rightSum + (mid - *left.rbegin() - 1) * (right.size() + 1);
      }
      if(now >= RL + RR && maxRight == 0){
        now = RL + RR;
        leftSum = RL;
        rightSum = RR;
        left.insert(mid);
        mid = *right.begin();
        right.erase(mid);
      }else if(now >= LL + LR){
        maxRight = 1;
        now = LL + LR;
        leftSum = LL;
        rightSum = LR;
        right.insert(mid);
        mid = *left.rbegin();
        left.erase(mid);
      }else{
        break;
      }
    }
    f[i] += now;
  }

  rep(i, N){
    cout << f[i];
    if(i == N-1) cout << endl;
    else cout << " ";
  }
}

int main(){
  solve();
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
const long double M_PI = 3.14159265358979323846265;
const ll INFL = 1LL << 60;//10^18 = 2^60
//ll MOD = 998244353;
void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}

const ll SIZE = 200010;
ll bit[SIZE];
void bit_add(ll i, ll x){//iは0-index
  i++;
  int cnt = 0;
  while(i < SIZE){
    bit[i] += x;
    i += i & -i;
  }
}

ll bit_sum(ll x){//xは0_index
  if(x < 0) return 0;
  x++;
  ll res = 0;
  while(x > 0){
    res += bit[x];
    x -= x & -x;
  }
  return res;
}

void bit_reset(){
  rep(i, SIZE) bit[i] = 0;
}

//区間加算区間和
const ll N_ = 1<<20;
ll seg[2][2 * N_ - 1], lazy[2][2 * N_ - 1];
ll m_seg[2 * N_ - 1];
void eval(ll id, ll k, ll l, ll r){
  if(lazy[id][k] == 0) return;
  seg[id][k] += lazy[id][k];
  m_seg[k] = min(seg[0][k], seg[1][k]);
  if(r - l > 1){
    lazy[id][2 * k + 1] += lazy[id][k] / 2;
    lazy[id][2 * k + 2] += lazy[id][k] / 2;
  }
  lazy[id][k] = 0;
}

void add(ll id, ll a, ll b, ll x, ll k = 0, ll l = 0, ll r = N_){
  eval(id, k, l, r);
  if(r <= a || b <= l) return;
  if(a <= l && r <= b){
    lazy[id][k] += (r - l) * x;
    eval(id, k, l, r);
    return;
  }
  add(id, a, b, x, 2 * k + 1, l, (l + r) / 2);
  add(id, a, b, x, 2 * k + 2, (l + r) / 2, r);
  seg[id][k] = seg[id][2 * k + 1] + seg[id][2 * k + 2];
  m_seg[k] = min(seg[0][k], seg[1][k]);
  return;
}

ll getsum(ll a, ll b, ll k = 0, ll l = 0, ll r = N_){
  if(r <= a || b <= l) return 0;
  eval(0, k, l, r);
  eval(1, k, l, r);
  if(a <= l && r <= b) return max(m_seg[k], 0LL);
  ll vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
  ll vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);
  return vl + vr;
}

void solve(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N){
    cin >> A[i];
    A[i]--;
  }
  vector<ll> pos(N);
  rep(i, N) pos[A[i]] = i;
  vector<ll> f(N);
  ll sum = 0;
  rep(i, N){
    sum += i - bit_sum(pos[i]);
    bit_add(pos[i], 1);
    f[i] = sum;
  }

  bit_reset();
  rep(i, N){
    add(0, pos[i], pos[i]+1, -INFL);
    add(1, pos[i], pos[i]+1, -INFL);
    add(0, pos[i]+1, N_, 1);
    add(1, 0, pos[i], 1);
    f[i] += getsum(0, N_);
  }

  rep(i, N){
    cout << f[i];
    if(i == N-1) cout << endl;
    else cout << " ";
  }
}

int main(){
  solve();
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
const long double M_PI = 3.14159265358979323846265;
const ll INFL = 1LL << 60;//10^18 = 2^60
//ll MOD = 998244353;
void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}

const ll SIZE = 200010;
ll bit[SIZE];
void bit_add(ll i, ll x){//iは0-index
  i++;
  int cnt = 0;
  while(i < SIZE){
    bit[i] += x;
    i += i & -i;
  }
}

ll bit_sum(ll x){//xは0_index
  if(x < 0) return 0;
  x++;
  ll res = 0;
  while(x > 0){
    res += bit[x];
    x -= x & -x;
  }
  return res;
}

void bit_reset(){
  rep(i, SIZE) bit[i] = 0;
}

void solve(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N){
    cin >> A[i];
    A[i]--;
  }
  vector<ll> pos(N);
  rep(i, N) pos[A[i]] = i;
  vector<ll> f(N);
  ll sum = 0;
  rep(i, N){
    sum += i - bit_sum(pos[i]);
    bit_add(pos[i], 1);
    f[i] = sum;
  }

  bit_reset();
  ll now = 0;
  ll mid = pos[0];
  bit_add(pos[0], 1);
  set<ll> left, right;
  ll leftSum = 0, rightSum = 0;
  for(ll i = 1; i < N; i++){
    bit_add(pos[i], 1);
    if(mid < pos[i]){
      //1 0 0 0 1 0 0 mid 0 0 new 0 0 1
      right.insert(pos[i]);
      rightSum -= bit_sum(SIZE-1) - bit_sum(pos[i]);
      rightSum += pos[i] - mid - 1 - (bit_sum(pos[i]-1) - bit_sum(mid));
    }else{
      //1 0 0 0 1 0 0 new 0 0 mid 0 0 1
      left.insert(pos[i]);
      leftSum -= bit_sum(pos[i]-1);
      leftSum += mid - pos[i] - 1 - (bit_sum(mid-1) - bit_sum(pos[i]));
    }
    now = leftSum + rightSum;

    while(true){
      ll LL, LR, RL, RR;
      if(right.size() == 0){//右に移動した時
        RL = INFL;
        RR = INFL;
      }else{
        RL = leftSum + (*right.begin() - mid - 1) * (left.size() + 1);
        RR = rightSum - (*right.begin() - mid - 1) * right.size();
      }
      if(left.size() == 0){
        LL = INFL;
        LR = INFL;
      }else{
        LL = leftSum - (mid - *left.rbegin() - 1) * left.size();
        LR = rightSum + (mid - *left.rbegin() - 1) * (right.size() + 1);
      }
      if(now > RL + RR){
        now = RL + RR;
        leftSum = RL;
        rightSum = RR;
        left.insert(mid);
        mid = *right.begin();
        right.erase(mid);
      }else if(now > LL + LR){
        now = LL + LR;
        leftSum = LL;
        rightSum = LR;
        right.insert(mid);
        mid = *left.rbegin();
        left.erase(mid);
      }else{
        break;
      }
    }
    f[i] += now;
  }

  rep(i, N){
    cout << f[i];
    if(i == N-1) cout << endl;
    else cout << " ";
  }
}

int main(){
  solve();
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
const long double M_PI = 3.14159265358979323846265;
const ll INFL = 1LL << 60;//10^18 = 2^60
//ll MOD = 998244353;
void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}

const ll SIZE = 200010;
ll bit[SIZE];
void bit_add(ll i, ll x){//iは0-index
  i++;
  int cnt = 0;
  while(i < SIZE){
    bit[i] += x;
    i += i & -i;
  }
}

ll bit_sum(ll x){//xは0_index
  x++;
  ll res = 0;
  while(x > 0){
    res += bit[x];
    x -= x & -x;
  }
  return res;
}

void bit_reset(){
  rep(i, SIZE) bit[i] = 0;
}
/*
//区間加算区間最小
const ll N_ = 1<<18;
ll seg[2][2 * N_ - 1], lazy[2][2 * N_ - 1];
void eval(ll id, ll k, ll l, ll r){
  if(lazy[id][k] == 0) return;
  seg[id][k] += lazy[id][k];
  if(r - l > 1){
    lazy[id][2 * k + 1] += lazy[id][k];
    lazy[id][2 * k + 2] += lazy[id][k];
  }
  lazy[id][k] = 0;
}

void add(ll id, ll a, ll b, ll x, ll k = 0, ll l = 0, ll r = N_){
  eval(id, k, l, r);
  if(r <= a || b <= l) return;
  if(a <= l && r <= b){
    lazy[id][k] += x;
    eval(id, k, l, r);
    return;
  }
  add(id, a, b, x, 2 * k + 1, l, (l + r) / 2);
  add(id, a, b, x, 2 * k + 2, (l + r) / 2, r);
  eval(id, k, l, r);
  seg[id][k] = min(seg[id][2 * k + 1], seg[id][2 * k + 2]);
  return;
}

ll getminimum(ll a, ll b, ll k = 0, ll l = 0, ll r = N_){
  if(r <= a || b <= l) return INFL;
  eval(0, k, l, r);
  eval(1, k, l, r);
  if(a <= l && r <= b) return seg[0][k] + seg[1][k];
  ll val = getminimum(a, b, 2 * k + 1, l, (l + r) / 2);
  ll var = getminimum(a, b, 2 * k + 2, (l + r) / 2, r);
  return min(val, var);
}
*/

void solve(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N){
    cin >> A[i];
    A[i]--;
  }
  vector<ll> pos(N);
  rep(i, N) pos[A[i]] = i;
  vector<ll> f(N);
  ll sum = 0;
  rep(i, N){
    sum += i - bit_sum(pos[i]);
    bit_add(pos[i], 1);
    f[i] = sum;
  }

  bit_reset();
  ll now = 0;
  ll mid = pos[0];
  bit_add(pos[0], 1);
  set<ll> left, right;
  ll leftSum = 0, rightSum = 0;
  for(ll i = 1; i < N; i++){
    bit_add(pos[i], 1);
    if(mid < pos[i]){
      right.insert(pos[i]);
      rightSum -= bit_sum(SIZE-1) - bit_sum(pos[i]);
      rightSum += pos[i] - mid - 1 - (bit_sum(pos[i]-1) - bit_sum(mid));
    }else{
      left.insert(pos[i]);
      leftSum -= bit_sum(pos[i]-1);
      if(i == 2){
      }
      leftSum += mid - pos[i] - 1 - (bit_sum(mid-1) - bit_sum(pos[i]));
    }
    now = leftSum + rightSum;

    while(true){
      ll LL, LR, RL, RR;
      if(right.size() == 0){//右に移動した時
        RL = INFL;
        RR = INFL;
      }else{
        RL = leftSum + (*right.begin() - mid - 1) * (left.size() + 1);
        RR = rightSum - (*right.begin() - mid - 1) * right.size();
      }
      if(left.size() == 0){
        LL = INFL;
        LR = INFL;
      }else{
        LL = leftSum - (mid - *left.rbegin() - 1) * left.size();
        LR = rightSum + (mid - *left.rbegin() - 1) * (right.size() + 1);
      }
      if(now > RL + RR){
        now = RL + RR;
        leftSum = RL;
        rightSum = RR;
        left.insert(mid);
        mid = *right.begin();
        right.erase(mid);
      }else if(now > LL + LR){
        now = LL + LR;
        leftSum = LL;
        rightSum = LR;
        right.insert(mid);
        mid = *left.rbegin();
        left.erase(mid);
      }else{
        break;
      }
    }
    f[i] += now;
  }

  rep(i, N){
    cout << f[i];
    if(i == N-1) cout << endl;
    else cout << " ";
  }
}

int main(){
  solve();
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define spc printf(" ")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007
#define FI freopen("input.txt","r",stdin)
#define FO freopen("output.txt","w",stdout)
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///#define triangle_area(a,b,m,n,x,y) (a*(n-y)+m*(y-b)+x*(b-n))/2.0
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction

using namespace __gnu_pbds;
using namespace std;

///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;

const int S=123456;
int main()
{
    /*idea: inversion counting + cost of gathering all indices of one
    in the median then spreading all the elements to its immediate lefts and rights position */

    #ifndef ONLINE_JUDGE
    FI;
    //FO;
    #endif
    //ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    while(si(n)==1)
    {
        int ara[n+5];
        int pos[n+5];
        for(int i=1;i<=n;i++)
        {
            si(ara[i]);
            pos[ara[i]]=i;
        }

        new_data_set pset;
        set<int>lset,rset;
        ll inv=0,lsum=0,rsum=0,spreading_cost=0;
        for(int i=1;i<=n;i++)
        {
            inv+=pset.size()-pset.order_of_key(pos[i]);
            pset.insert(pos[i]);
            if(rset.empty() || pos[i]<*rset.begin())
            {
                lset.insert(pos[i]);
                lsum+=pos[i];
            }
            else
            {
                rset.insert(pos[i]);
                rsum+=pos[i];
            }

            //balancing set
            if(rset.size()+1<lset.size())
            {
                int x=*lset.rbegin();
                auto it=lset.end();
                it--;
                lset.erase(it);
                rset.insert(x);
                lsum-=x;
                rsum+=x;
            }
            else if(rset.size()>lset.size())
            {
                int x=*rset.begin();
                rset.erase(rset.begin());
                lset.insert(x);
                rsum-=x;
                lsum+=x;
            }
            ll median=*lset.rbegin();
            ll gathering_cost=(rsum-rset.size()*median)+(lset.size()*median-lsum);
            spreading_cost+=i/2;
            pf("%lld\n",inv+gathering_cost-spreading_cost);
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct SEG{
	struct node{
		int l,r; ll req;
	}tree[1<<22]; int tn=1;
	void make(int a){
		if(a>=tn) return;
		make(2*a); make(2*a+1);
		tree[a].l=tree[2*a].l; tree[a].r=tree[2*a+1].r;
		tree[a].req=tree[2*a].req+tree[2*a+1].req;
	}
	void init(int n){
		while(tn<n) tn*=2;
		for(int i=tn;i<2*tn;i++) tree[i].l=tree[i].r=i-tn+1, tree[i].req=0;
		make(1);
	}
	void update(int a, int s, ll d){
		if(s<tree[a].l || tree[a].r<s);
		else if(s<=tree[a].l && tree[a].r<=s) tree[a].req=d;
		else{
			update(2*a,s,d); update(2*a+1,s,d);
			tree[a].req=tree[2*a].req+tree[2*a+1].req;
		}
	}
	ll query(int a, int s, int d){
		if(d<tree[a].l || tree[a].r<s) return 0;
		else if(s<=tree[a].l && tree[a].r<=d) return tree[a].req;
		else return query(2*a,s,d)+query(2*a+1,s,d);
	}
}seg;

int N, arr[200001];
int where[200001];
int main(){
	cin>>N;
	for(int i=1;i<=N;i++){
		cin>>arr[i]; where[arr[i]]=i;
	}
	seg.init(N);
	int ans=0;
	cout<<0<<' ';
	int wo=where[1]; seg.update(1,where[1],1);
	for(int i=2;i<=N;i++){
		if(where[i]<wo){
			ans+=wo-where[i]-1-seg.query(1,where[i],wo-1)+i-1;
		} else {
			ans+=where[i]-wo-1-seg.query(1,wo+1,where[i]);
		}
		seg.update(1,where[i],1);
		cout<<ans<<' ';
	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
struct SEG{
	struct node{
		int l,r; ll req;
	}tree[1<<22]; int tn=1;
	void make(int a){
		if(a>=tn) return;
		make(2*a); make(2*a+1);
		tree[a].l=tree[2*a].l; tree[a].r=tree[2*a+1].r;
		tree[a].req=tree[2*a].req+tree[2*a+1].req;
	}
	void init(int n){
		while(tn<n) tn*=2;
		for(int i=tn;i<2*tn;i++) tree[i].l=tree[i].r=i-tn+1, tree[i].req=0;
		make(1);
	}
	void update(int a, int s, ll d){
		if(s<tree[a].l || tree[a].r<s);
		else if(s<=tree[a].l && tree[a].r<=s) tree[a].req=d;
		else{
			update(2*a,s,d); update(2*a+1,s,d);
			tree[a].req=tree[2*a].req+tree[2*a+1].req;
		}
	}
	ll query(int a, int s, int d){
		if(d<tree[a].l || tree[a].r<s) return 0;
		else if(s<=tree[a].l && tree[a].r<=d) return tree[a].req;
		else return query(2*a,s,d)+query(2*a+1,s,d);
	}
	int kth(ll a){
		int ret=n,l=1,r=n,mid;
		ll p;
		while(l<=r){
			mid=(l+r)/2;
			p=query(1,1,mid);
			if(p>=a) ret=min(ret,mid),r=mid-1;
			else l=mid+1;
		}
		return ret;
	}
}seg,seg2;
ll arr[200001], pos[200001], pfx[200001];
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){ cin>>arr[i]; pos[arr[i]]=i; }
    seg.init(n); seg2.init(n);
	for(int i=1;i<=n;i++){
		ll ans=pfx[i]=pfx[i-1]+seg.query(1,pos[i]+1,n);
		seg.update(1,pos[i],1); seg2.update(1,pos[i],pos[i]);
		int mid=seg.kth((i+1)/2);
		ans+=seg2.query(1,mid+1,n)-seg2.query(1,1,mid-1)-mid*(1-i%2)-((i+1)/2-1)*((i+1)/2)/2-(i-(i+1)/2)*(i-(i+1)/2+1)/2;
		cout<<ans<<'\n';
	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
struct SEG{
	struct node{
		int l,r; ll req;
	}tree[1<<22]; int tn=1;
	void make(int a){
		if(a>=tn) return;
		make(2*a); make(2*a+1);
		tree[a].l=tree[2*a].l; tree[a].r=tree[2*a+1].r;
		tree[a].req=tree[2*a].req+tree[2*a+1].req;
	}
	void init(int n){
		while(tn<n) tn*=2;
		for(int i=tn;i<2*tn;i++) tree[i].l=tree[i].r=i-tn+1, tree[i].req=0;
		make(1);
	}
	void update(int a, int s, ll d){
		if(s<tree[a].l || tree[a].r<s);
		else if(s<=tree[a].l && tree[a].r<=s) tree[a].req=d;
		else{
			update(2*a,s,d); update(2*a+1,s,d);
			tree[a].req=tree[2*a].req+tree[2*a+1].req;
		}
	}
	ll query(int a, int s, int d){
		if(d<tree[a].l || tree[a].r<s) return 0;
		else if(s<=tree[a].l && tree[a].r<=d) return tree[a].req;
		else return query(2*a,s,d)+query(2*a+1,s,d);
	}
	int kth(ll a){
		int ret=n,l=1,r=n,mid;
		ll p;
		while(l<=r){
			mid=(l+r)/2;
			p=query(1,1,mid);
			if(p>=a) ret=min(ret,mid),r=mid-1;
			else l=mid+1;
		}
		return ret;
	}
}seg,seg2;
ll arr[200001], pos[200001], pfx[200001];
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){ cin>>arr[i]; pos[arr[i]]=i; }
    seg.init(n); seg2.init(n);
	for(int i=1;i<=n;i++){
		ll ans=pfx[i]=pfx[i-1]+seg.query(1,pos[i]+1,n);
		seg.update(1,pos[i],1); seg2.update(1,pos[i],pos[i]);
		ll mid=seg.kth((i+1)/2);
		ans+=seg2.query(1,mid+1,n)-seg2.query(1,1,mid-1)-mid*(1-i%2)-1ll*((i+1)/2-1)*((i+1)/2)/2-1ll*(i-(i+1)/2)*(i-(i+1)/2+1)/2;
		cout<<ans<<' ';
	}
}