//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
// static const ll MOD = (1LL << 61LL) - 1LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s)
{
	ll v;
	istringstream sin(s);
	sin >> v;
	return v;
}
template <class t>
inline string tostring(t x)
{
	ostringstream sout;
	sout << x;
	return sout.str();
}

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a); (i) < (ll)(b); (i)++)
#define REPD(i, a, b) for (ll i = (ll)(a); (i) < (ll)(b); (i)++)
#define REPI(v, vs) for (auto &v : vs)

//debug
#ifdef LOCAL_ENV
#define DUMP(x) cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" \
					  << " " << __FILE__ << endl
#else
#define DUMP(x)
#define DEBUG(x)
#endif

#define MAX_VALUE 9223372036854775807LL

template <ull N, class T, class... Args, std::enable_if_t<N == 0, int> = 0>
auto make_multiple_vector(Args... args)
{
	return T(args...);
}

template <ull N, class T, class... Args, std::enable_if_t<N != 0, int> = 0>
auto make_multiple_vector(ull size, Args... args)
{
	using value_type = std::decay_t<decltype(make_multiple_vector<N - 1, T>(args...))>;
	return vector<value_type>(size, make_multiple_vector<N - 1, T>(args...));
}

template <class Integer>
class BinaryIndexedTree
{
private:
	ull maxSize_;
	vector<Integer> values_;

public:
	BinaryIndexedTree(ull maxSize) : maxSize_(maxSize), values_(maxSize_, 0) {}

	void update(ll index, Integer increment)
	{
		if (maxSize_ <= index)
		{
			throw invalid_argument("Index should be less than maxSize.");
		}
		++index;

		while (index <= maxSize_)
		{
			values_[index - 1] += increment;
			index += index & -index;
		}
	}

	Integer query(ll index)
	{
		if (index < 0LL)
			return 0;
		if (maxSize_ <= index)
		{
			throw invalid_argument("Index should be less than maxSize.");
		}
		++index;

		Integer res = 0;
		while (index > 0)
		{
			res += values_[index - 1];
			index -= index & -index;
		}
		return res;
	}
};
using BIT = BinaryIndexedTree<ll>;

int solve()
{
	ll n;
	cin >> n;

	vector<ll> as(n);
	REPD(i, 0, n)
	cin >> as[i];

	ll res = n * (n - 1) / 2;
	BIT bit(n);
	REPD(i, 0, n)
	{
		res -= bit.query(as[i]);
		bit.update(as[i], 1);
	}

	REPD(i, 0, n)
	{
		cout << res << endl;
		res += n - as[i] * 2 - 1;
	}

	return 0;
}

//main function
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}

#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);

int n;
int a[600005];
int loga[300005];
int desno[600005];
int lijevo[600005];

void update(int x, int y) {
	x++;
	for (; x <= n; x += x & -x) loga[x] += y;
}

int query(int x) {
	int out = 0;
	x++;
	for (; x > 0; x -= x & -x) out += loga[x];
	return out;
}

int main () {

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i+n] = a[i];
	}
	
	for (int i = 2*n-1; i >= 0; i--) {
		desno[i] = query(a[i]-1);
		update(a[i], 1);
	}
	
	ll sol = 0;
	memset(loga, 0, sizeof loga);
	for (int i = 0; i < n; i++) {
		lijevo[i] = query(n-1)-query(a[i]);
		update(a[i], 1);
		sol += lijevo[i];
	}
	
	cout << sol << "\n";
	
	for (int i = n; i < 2*n-1; i++) {
		lijevo[i] = query(n-1)-query(a[i]);
		update(a[i], 1);
		
		sol += lijevo[i];
		sol -= lijevo[i-n];
		sol -= desno[i-n];
		sol += desno[i];
		
		cout << sol << "\n";
	}

	return 0;
}
