#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(v.begin(), v.begin()+n/2); vector h2(v.begin()+n/2, v.end()); ll t1 = tentou(h1); ll t2 = tentou(h2); sort(h1.begin(), h1.end()); sort(h2.begin(), h2.end()); ll idx=0; ll ans = t1+t2; for(auto x : h1) { while(idx> 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 << "\n"; rep(i, n-1) { cnt-=smaller[v[i]]; cnt+=bigger[v[i]]; cout << cnt<<"\n"; } return 0; }