#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
using ll = long long;

typedef tree<
int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;


const int ac = 2e6 + 10, bc = (1 << 20);
int A[ac]; 
int T[bc * 2];

void update(int v)
{
	v += bc;
	T[v] = 1;
	while (v)
	{
		v /= 2;
		T[v] = T[v * 2] + T[v * 2 + 1];
	}
}

int query(int a, int b)
{
	if (a > b) return 0;
	a += bc; b += bc;
	int s = T[a];
	if (a != b) s += T[b];
	while (a / 2 != b / 2)
	{
		if (a % 2 == 0) s += T[a + 1];
		if (b % 2 == 1) s += T[b - 1];
		a /= 2; b /= 2;
	}
	return s;
}


int T2[bc * 2];

void update2(int v)
{
	v += bc;
	T2[v] = v - bc;
	while (v)
	{
		v /= 2;
		T2[v] = T2[v * 2] + T2[v * 2 + 1];
	}
}

int query2(int a, int b)
{
	if (a > b) return 0;
	a += bc; b += bc;
	int s = T2[a];
	if (a != b) s += T2[b];
	while (a / 2 != b / 2)
	{
		if (a % 2 == 0) s += T2[a + 1];
		if (b % 2 == 1) s += T2[b - 1];
		a /= 2; b /= 2;
	}
	return s;
}

ll n; 

long long sum(long long a)
{
	return a * (a + 1) / 2;
}

long long dist(ordered_set& S, int x)
{
	S.insert(x);
	update2(x);
	auto v = *S.find_by_order(S.size() / 2);
	ll s = query2(v + 1, n - 1) - sum(query(v + 1, n - 1)) - query(v + 1, n - 1) * v
		+ query(0, v - 1) * v - query2(0, v - 1) - sum(query(0, v - 1));
	return s;
}

bool cmp(int a, int b)
{
	return A[a] <= A[b];
}
	
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> A[i];
	vector<int> O;
	for (int i = 0; i < n; i++) O.push_back(i);
	sort(O.begin(), O.end(), cmp);

	long long inv = 0;
	ordered_set S;
	for (int i = 0; i < n; i++)
	{
		inv += query(O[i], n - 1);
		update(O[i]);
		auto d = dist(S, O[i]);


		cout << inv + d << ' ';
	}
	cout << '\n';
}
