#include using namespace std; struct Ftree { vector dat; Ftree(int n) : dat(n, 0) {} void add(int x) { for (int i = x; i < dat.size(); i += i & -i) ++dat[i]; } int sum(int x) { int res = 0; for (int i = x; i; i -= i & -i) res += dat[i]; return res; } }; struct MapZstar { vector dsc; map mp; MapZstar(const vector &d) { dsc = d; sort(dsc.begin(), dsc.end()); dsc.erase(unique(dsc.begin(), dsc.end()), dsc.end()); for (int i = 0; i < dsc.size(); ++i) mp[dsc[i]] = i; } }; signed main() { ios::sync_with_stdio(false); int N; cin >> N; vector A(N); for (int i = 0; i < N; ++i) cin >> A[i]; MapZstar mz(A); Ftree f(mz.dsc.size() + 1); int64_t cur = 0; for (int i = 0; i < N; ++i) { cur += f.sum(f.dat.size() - 1) - f.sum(mz.mp[A[i]] + 1); f.add(mz.mp[A[i]] + 1); } for (int i = 0; i < N; ++i) { cout << cur << endl; cur += f.sum(f.dat.size() - 1) - f.sum(mz.mp[A[i]] + 1); cur -= f.sum(mz.mp[A[i]]); } }