#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <complex>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <queue>

#define	INF   1010101010LL
#define INFLL 1010101010101010101LL

using namespace std;

int mod = 1000000007;
//int mod = 998244353;

class BIT {
public:
	BIT(int n) : a(n) {}

	void add(int p, long long num)
	{
		while (p < a.size()) {
			a[p] += num;
			p |= p + 1;
		}
	}

	/* i から j までの和 [i, j] */
	long long sum(int i, int j)
	{
		long long s = 0, t = 0;
		i--;
		while (i >= 0) {
			s += a[i];
			i = (i & (i + 1)) - 1;
		}
		while (j >= 0) {
			t += a[j];
			j = (j & (j + 1)) - 1;
		}
		return t - s;
	}

	void print()
	{
		for (int i = 0; i < a.size(); i++) {
			cout << a[i] << endl;
		}
	}

private:
	vector<long long> a;
};

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	vector<long long> b(n), c(n), d(n), e(n);
	BIT bit(n);
	long long t = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = bit.sum(a[i] + 1, n - 1);
		d[i] = n - b[i] - 1;
		t += b[i];
		bit.add(a[i], 1);
	}
	BIT bit1(n);
	for (int i = n - 1; i >= 0; i--) {
		c[i] = bit1.sum(a[i] + 1, n - 1);
		e[i] = n - c[i] - 1;
		bit1.add(a[i], 1);
	}
	
	for (int i = 0; i < n; i++) {
		cout << t << endl;
		t -= a[i];
		t += n - 1 - a[i];
	}
	

	return 0;
}
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#include<cmath>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y,ll z){
    
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        ll w=(p*p)%z;
        if(y%2==0)
         return w;
        else
        return (x*w)%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll n;
    cin>>n;
    ll a[200]={0},c=0;
    for(int i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        a[x%200]++;
    }
    for(int i=0;i<200;i++)
    {
        c=c+(a[i]*a[i]-a[i])/2;
    }
    cout<<c;}