#include<bits/stdc++.h>

using namespace std;

using ll = long long int;
using vi = vector<int>;
#define f(n) for(int i = 0; i < n; i++)
#define fj(n) for(int j = 0; j < n; j++)
#define fk(n) for(int k = 0; k < n; k++)
#define ci(n) cin >> n;
#define ic(n) int n; cin >> n;
#define lc(n) int n; cin >> n;
#define all(a) a.begin(), a.end()
#define pri(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << "\n";
#define scl(a, n) ll a[n] = {0}; for(int i = 0; i < n; i++) cin >> a[i];
#define pb push_back
#define eb emplace_back
#define sc second
#define ft first
#define int long long
void prip(int a[], int n){f(n) cout << a[i] << ' '; cout << '\n';}

const int inf = 2e9, mxp = 10, maxn = 2e6, mod = 1e9 + 7;
int bp(int a, int n)
{
    if(n == 0) return 1;
    if(n & 1ll) return (a * bp(a, n - 1)) % mod;
    int res = bp(a, n >> 1);
    return (res * res) % mod;
}
int fc[maxn + 1], rc[maxn + 1];
int cnk(int n, int k)
{
    if(k > n) return 0;
    int ans = (fc[n] * rc[k]) % mod;
    return (ans * rc[n - k]) % mod;
}

long long ans = 0;
void INVERSIONS(long long a[], int l, int r)
{
    if (r - l <= 1)
    {
        return;
    }
    int m = (l + r) / 2;
    INVERSIONS(a, l, m);
    INVERSIONS(a, m, r);
    long long b[r - l];
    int ll = l, rr = m;
    while (ll < m && rr < r)
    {
        if (a[ll] <= a[rr])
        {
            b[ll - l + rr - m] = a[ll];
            ll++;
        }
        else
        {
            b[ll - l + rr - m] = a[rr];
            rr++;
            ans += m - ll;
        }
    }
    while (ll < m)
    {
        b[ll - l + rr - m] = a[ll];
        ll++;
    }
    while (rr < r)
    {
        b[ll - l + rr - m] = a[rr];
        rr++;
    }
    for (int i = l; i < r; i++)
    {
        a[i] = b[i - l];
    }
}
main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ic(n)
    int a[2 * n], ta[n];
    f(n) cin >> a[i], a[i + n] = a[i], ta[i] = a[i];
    INVERSIONS(ta, 0, n);
    cout << ans << '\n';
    for(int i = 0; i < n - 1; i++) {
        ans += (n - a[i + n] - 1);
        ans -= a[i];
        cout << ans << '\n';
    }
}

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long double ld;
#define f first
#define s second

const int N = 3e5 + 100;
const int sq = 100;
const ll mod = 95542721;
const int inf = 1e7;

ll seg[4*N], a[N], ind[N], n;

void add(int x, int b = 0, int e = n, int ind = 1)
{
	if(b + 1 == e)
	{
		seg[ind]++;
		return;
	}
	int mid = (b + e) / 2;
	if(x < mid)
		add(x, b, mid, ind*2);
	else
		add(x, mid, e, ind*2+1);
	
	seg[ind] = seg[ind*2] + seg[ind*2+1];	
}


ll get(int l, int r, int b = 0, int e = n, int ind = 1)
{
	if(r <= b || e <= l)
		return 0;
	if(l <= b && e <= r)
		return seg[ind];
	
	int mid =(b + e) / 2;
	return get(l, r, b, mid, ind*2) + get(l, r, mid, e, ind*2+1); 	
}



int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);	

	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		ind[a[i]] = i;
	}
	ll inv = 0;
	for(int i = n-1; i >= 0; i--)
	{
		add(ind[i]);
		inv += get(0, ind[i]);
		//cout << ind[i] << ' ' << get(0, ind[i]) << endl;
	}	
	
	cout << inv << endl;
	for(int i = 0; i < n-1; i++)
	{
		inv = inv - a[i] + (n - a[i] - 1);
		cout << inv << endl;
	}
	

	
	
	return 0;
}



 
 