#include<bits/stdc++.h>

using namespace std;

const int maxN  = 1e6 + 10;
#define pb push_back

int a[maxN];
string s;
int n;
vector<int> v[maxN];
int bit[maxN];

void update(int x, int poz)
{
    for (int i = poz;i<maxN;i+=i&-i)
    	bit[i]+=x;
    
}

int get(int poz)
{
	int ans = 0;

	for (int i = poz;i>0;i-=i&-i)
		ans+=bit[i];

	return ans;
}
int main()
{  
	cin>>n;
    
	for (int i = 1;i<=n;i++){
		scanf("%d",&a[i]);
		a[i]++;
	}

    long long ans = 0;

    for (int i = 1;i<=n;i++)
    {
       ans+=i - 1 - get(a[i]);
       update(1, a[i]);
    }

    int cur = 1;
    for (int i = 1;i<=n;i++)
    {
    	printf("%lld\n", ans);
        ans-=a[cur] - 1;
        ans+=n - a[cur];
        cur++;
    }

	return 0;
}
#include<bits/stdc++.h>
using namespace std;

#define FASTIO	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(A,val) memset(A,val,sizeof(A))
#define fi(a,b) for(int i=a;i<=b;++i)
#define fj(a,b) for(int j=a;j<=b;++j)
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define pii pair<int,int>
#define DEBUG(a...) cout<<#a<<": ";for(auto &it:a)cout<<it<<" ";cout<<"\n";
#define debug(a)cout<<#a<<": "<<a<<"\n";
#define int long long

// ---------------------------------------------------------------------------
const int mod = 1e9+7;
const int maxn = 3e5 + 9;
vi BIT(maxn);
// ---------------------------------------------------------------------------
int sum(int i){
	int ans = 0;
	while(i>0){
		ans+=BIT[i];
		i-=(i&(-i));
	}
	return ans;
}
void update(int i,int x,int n){
	while(i<=n){
		BIT[i]+=x;
		i+=(i&(-i));
	}
}
// ---------------------------------------------------------------------------
void test_case(int tc)
{
	// cout<<"Case #"<<tc<<": ";
	int n;cin>>n;
	vector<int>arr(n+1);fi(1,n)cin>>arr[i],arr[i]++;
	int inversion = 0;
	for(int i=1;i<=n;++i){
		inversion+=(sum(n)-sum(arr[i]));
		update(arr[i],1,n);
	}
	cout<<inversion<<"\n";
	for(int i=1;i<n;++i){
		inversion+=(n-arr[i]);
		inversion-=(arr[i]-1);
		cout<<inversion<<"\n";
	}
}

int32_t main()
{
	FASTIO;
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif
	
	int t=1;
	//cin>>t;
	for(int tc=1;tc<=t;++tc)test_case(tc);
}