#include using namespace std; using ll = long long; template using vt = vector; template using vvt = vector>; template using ttt = tuple; using tii = tuple; using vi = vector; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define pb push_back #define mt make_tuple #define ALL(a) (a).begin(),(a).end() #define FST first #define SEC second #define DEB cerr<<"!"<0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;} inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;} /*Coding Space*/ template struct BIT{ vector d; BIT(size_t n):d(n+1){} T sum(size_t i){T s{};for(++i;i>0;i-=i&-i)s+=d[i];return s;} T sum(size_t i,size_t j){return i?sum(j)-sum(i-1):sum(j);} void add(size_t i,T x){for(++i;i a){ // n = a.size O(n log n) BIT bit(500050); ll ret = 0; rep(i,a.size()){ ret += i - bit.sum(a[i]); bit.add(a[i],1); } return ret; } int main(){ int n; cin >> n; vt in(n); rep(i,n)cin >> in[i]; ll ans = inversion(in); vt t(n); rep(i,n) t[i] = in[i]; sort(ALL(t)); rep(i,n){ if(i == 0)cout << ans << endl; else{ int lower = distance(t.begin(), lower_bound(ALL(t),in[i-1])); int upper = distance(upper_bound(ALL(t), in[i-1]) , t.end()); //cerr << i << " " << lower << " " << upper << endl; ans = ans - lower + upper; cout << ans << endl; } } }