#include using namespace std; #define ll long long #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) ll tentou(vector v) { if(v.size()<=1) { return 0; } ll n = v.size(); vector h1; vector h2; for(int i=0; i> n; vector v(n); map m; rep(i, n) { cin >> v[i]; if(m.find(v[i])!=m.end()) { m[v[i]]++; } else { m[v[i]]=1; } } map bigger; map smaller; { ll acc = 0; for(auto itr : m) { smaller[itr.first] = acc; bigger[itr.first] = n-acc-itr.second; acc+=itr.second; } } ll cnt = tentou(v); cout << cnt << endl; rep(i, n-1) { cnt-=smaller[v[i]]; cnt+=bigger[v[i]]; cout << cnt<