#include<bits/stdc++.h>usingnamespacestd;usingll=longlong;llN;vector<ll>hairs,tree;voidupdate(lli,llx){while(i<tree.size()){tree[i]+=x;i=i+(i&(-i));}}llquery(lli){llans=0;while(i>0){ans+=tree[i];i=i-(i&(-i));}returnans;}intmain(){ifstreamcin("haircut.in");ofstreamcout("haircut.out");cin>>N;hairs.resize(N+1);tree.resize(N+2);vector<int>inverse(N+1);for(inti=1;i<N+1;i++){cin>>hairs[i];hairs[i]++;// i - 1 = values before, also query(N + 1)inverse[i]=i-1-query(hairs[i]);update(hairs[i],1);}vector<int>order(N);// get new orderiota(order.begin(),order.end(),1);sort(order.begin(),order.end(),[](inta,intb){returnhairs[a]<hairs[b];});llans=0;inti=0;cout<<ans<<endl;for(intj=1;j<N;j++){while(i<N&&hairs[order[i]]<=j){ans+=inverse[order[i]];i++;}cout<<ans<<endl;}}