W=[0]*9**6 a=ARGF.gets_to_end.split.map(&.to_i) n=a.shift z=(1..n).to_a.sort{|i,j|a[i-1]!=a[j-1] ? a[i-1]<=>a[j-1]: i<=>j} r=0_i64 i=n while 0<=(i-=1) k=z[i];while k>0;r+=W[k];k&=k-1 end k=z[i];while k<=n;W[k]+=1;k+=k&-k end end b=a.sort n.times{|i|puts r;r-=((0...n).bsearch{|j|a[i]<=b[j]}||n)-n+((0...n).bsearch{|j|a[i]