#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>  
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<ll> v32;
typedef vector<vector<ll> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define vvv64 vector<vv32>
#define vvvv64 vector<vvv32>

#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include  <bits/stdc++.h>
using namespace __gnu_pbds; 
using namespace std; 
  
// a new data structure defined. Please refer below 
// GNU link : https://goo.gl/WVDL6g 
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
tr; 


int LIM=2e5+100;
v64 t1(4*LIM);
v64 t2(4*LIM);
v64 l1(4*LIM);
v64 l2(4*LIM);

void updateRange(int node, int start, int end, int l, int r, int val,v64 &lazy,v64 &tree)
{
    if(lazy[node] != 0)
    { 
        // This node needs to be updated
        tree[node] += (end - start + 1) * lazy[node];    // Update it
        if(start != end)
        {
            lazy[node*2] += lazy[node];                  // Mark child as lazy
            lazy[node*2+1] += lazy[node];                // Mark child as lazy
        }
        lazy[node] = 0;                                  // Reset it
    }
    if(start > end or start > r or end < l)              // Current segment is not within range [l, r]
        return;
    if(start >= l and end <= r)
    {
        // Segment is fully within range
        tree[node] += (end - start + 1) * val;
        if(start != end)
        {
            // Not leaf node
            lazy[node*2] += val;
            lazy[node*2+1] += val;
        }
        return;
    }
    int mid = (start + end) / 2;
    updateRange(node*2, start, mid, l, r, val,lazy,tree);        // Updating left child
    updateRange(node*2 + 1, mid + 1, end, l, r, val,lazy,tree);   // Updating right child
    tree[node] = tree[node*2] + tree[node*2+1];        // Updating root with max value 
}

int queryRange(int node, int start, int end, int l, int r,v64 &lazy,v64 &tree)
{
    if(start > end or start > r or end < l)
        return 0;         // Out of range
    if(lazy[node] != 0)
    {
        // This node needs to be updated
        tree[node] += (end - start + 1) * lazy[node];            // Update it
        if(start != end)
        {
            lazy[node*2] += lazy[node];         // Mark child as lazy
            lazy[node*2+1] += lazy[node];    // Mark child as lazy
        }
        lazy[node] = 0;                 // Reset it
    }
    if(start >= l and end <= r)             // Current segment is totally within range [l, r]
        return tree[node];
    int mid = (start + end) / 2;
    int p1 = queryRange(node*2, start, mid, l, r,lazy,tree);         // Query left child
    int p2 = queryRange(node*2 + 1, mid + 1, end, l, r,lazy,tree); // Query right child
    return (p1 + p2);
}


void solve()
{
	int n;
	cin>>n;
	v64 pos(n+1);
	for (int i=1; i<=n; i++)
	{
		int temp;
		cin>>temp;
		pos[temp]=i;
	}
	ll count=0;
	tr tree;
	ll mini=1e9;
	ll maxi=0;
	v64 zero(n,0);
	for (int i=1; i<=n; i++)
	{
		updateRange(1,1,n,pos[i]+1,n,1,l1,t1);
		updateRange(1,1,n,1,pos[i]-1,1,l2,t2);
		count+=i-1-tree.order_of_key(pos[i]);
		tree.insert(pos[i]);

		mini=min(mini,pos[i]);
		maxi=max(maxi,pos[i]);
		int mid=*tree.find_by_order(i/2);
		ll a=(i+1)/2;
		ll b=i-a;
		ll total=queryRange(1,1,n,mid,maxi,l2,t2) + queryRange(1,1,n,mini,mid-1,l1,t1) - (a*(a-1))/2 - (b*(b-1))/2;
		ll ans=total+count;
		cout<<ans<<" ";
	}
	// cout<<"a"<<endl;
}   
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
 //    int n=5;
 //    v64 zero(n,0);
	// LazySegmentTree l(zero),r(zero);
	// l.inc(0,5,1);
	// // l.inc(1,4,1);
	// cout<<l.query(0,5)<<" "<<n<<endl;

    // cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}