#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long 
#define vl vector<ll>
#define vs vector<string>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define sl set<ll>
#define pql priority_queue<ll>

#define rep(i,n) for(i=0;i<n;i++)
#define repr(i,n) for(i=n-1;i>=0;i--)
#define REP(i,a,b) for(i=a;i<b;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(), a.rend()
#define vsort(a) sort(all(a))
#define rvsort(a) sort(rall(a))

#define F first
#define S second
#define pi acos(-1)
#define inf 10000000000000000
#define mod 1000000007
#define MA LLONG_MAX
#define MI LLONG_MIN

long long power(long long x,ll y)
{
    long long res = 1; 
    x = x % mod;
    while (y > 0) 
    {
        if (y & 1)
            res = (res * x) % mod;
        y = y >> 1; 
        x = (x * x) % mod;
    }
    return res;
}

long modInverse(long long n)
{
    return power(n, mod - 2);
}

long long ncr(long long n, ll r)
{
    if (n < r)
        return 0;
    if (r == 0)
        return 1;
    long long fac[n + 1];
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = (fac[i - 1] * i) % mod;
 
    return (fac[n] * modInverse(fac[r]) % mod*modInverse(fac[n - r])% mod)% mod;
}
 

void solve()
{
    ll n,i,ans=0;
    cin>>n;
    ll sum=0;
    vl a(n);
    rep(i,n)
    cin>>a[i];
    ordered_set s;
    for(i=0;i<n;i++)
    {
        ans+=s.size()-s.order_of_key(a[i]);
        s.insert(a[i]);
    }
    cout<<ans<<endl;
    for(i=0;i<n-1;i++)
    {
        ans+=(n-a[i]-1);
        ans-=a[i];
        cout<<ans<<endl;
    }
}
    
int32_t main() {
	ios_base::sync_with_stdio(false);
   cin.tie(NULL); cout.tie(NULL);
// #ifdef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	
	int t=1;
	//cin>>t;
	while (t--) {
		solve();
	}
	return 0;
}
#include <bits/stdc++.h>
#include <iostream>
#include <stdlib.h>
using namespace std;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>

#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vpi vetor<pii>
#define vpl vector<pll>
#define pb push_back
#define all(v) v.begin(),v.end()
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL);


void cout_vector(vi v){
	
	for (ll unsigned i=0; i<v.size(); i++) cout << v[i] << " ";
	cout<<endl;
}

int sum_vector(vi v){
	return accumulate(all(v),0);
}

void sort_vector(vi&v){
	sort(all(v));
}

void sort_comp(vi &v, bool func(int,int)){
	sort(all(v),func);
}

bool comp(array<int,2> a,array<int,2> b){
	return a[0]+a[1]<b[0]+b[1];
}

ll gcd(ll a, ll b){
	while(a){
		ll temp =a;
		a=b%a;
		b=temp;
	}
	return b;
}

ll lcm(ll a, ll b){
	return (a*b)/gcd(a,b);
}

string binary(ll num){
	string ans="";
	do{
		ans=to_string(num%2)+ans;
		num/=2;
	}while(num);
	return ans;
}


const int mxn = 2e3+7;
const ll mod = 1e9+7; 

ll pwr(ll num, ll p, ll modi){
	ll res=1;
	while(p>0){
		if(p&1){res*=num; res%=modi;}
		num*=num;
		num%=modi;
		p/=2;
	}
	return res; 
}

ll inverse(ll num){
	return pwr(num,mod-2,mod);
}



void solve(){
	int n;
	cin>>n;
	string a,b;
	cin>>a;
	for(int i=0; i<n;i++){
		if(b.size()<=1) b+=a.at(i);
		else{
			int bs=b.size();
			if(b.at(bs-2)=='f' && b.at(bs-1)=='o' && a.at(i)=='x'){
				b.pop_back();
				b.pop_back();
			}
			else{
				b+=a.at(i);
			}
		}
	}
	cout<<b.size();
}


int main()
{
	fast_io
	int t;
	//cin>>t;
	t=1;
	while(t--) solve();
	
	
	return 0;
}
