#include <bits/stdc++.h>
using namespace std;
#define maxn 100010
#define ena long long
ena n;
ena a[maxn], cnt[maxn], st[4*maxn], ans[maxn];
vector <ena> vitri[maxn];
void update(ena node, ena l, ena r, ena id, ena val)
{
if(id < l || id > r) return;
if(l == r)
{
st[node] += val;
return;
}
ena mid = (l + r)/2;
update(2*node, l, mid, id, val);
update(2*node+1, mid+1, r, id, val);
st[node] = st[2*node] + st[2*node+1];
}
ena get(ena node, ena l, ena r, ena u, ena v)
{
if(v < l || r < u) return 0;
if(u <= l && r <= v) return st[node];
ena mid = (l + r)/2;
ena L = get(2*node, l, mid, u, v);
ena R = get(2*node+1, mid+1, r, u, v);
return (L + R);
}
int main()
{
freopen("daonguoc.inp","r",stdin);
freopen("daonguoc.out","w",stdout);
cin >> n;
for(ena i=1; i<=n; i++)
{
cin >> a[i];
cnt[i] = get(1, 0, n, a[i] + 1, n);
update(1, 0, n, a[i], 1);
vitri[a[i]].push_back(i);
ans[n] += cnt[i];
}
for(ena i=n-1; i>=0; i--)
{
ans[i] = ans[i+1];
for(ena id:vitri[i])
{
ans[i] -= cnt[id];
}
}
for(ena i=0; i<=n-1; i++)
cout << ans[i] << "\n";
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIG1heG4gMTAwMDEwCiNkZWZpbmUgZW5hIGxvbmcgbG9uZwoKZW5hIG47CmVuYSBhW21heG5dLCBjbnRbbWF4bl0sIHN0WzQqbWF4bl0sIGFuc1ttYXhuXTsKCnZlY3RvciA8ZW5hPiB2aXRyaVttYXhuXTsKCnZvaWQgdXBkYXRlKGVuYSBub2RlLCBlbmEgbCwgZW5hIHIsIGVuYSBpZCwgZW5hIHZhbCkKewogICAgaWYoaWQgPCBsIHx8IGlkID4gcikgcmV0dXJuOwogICAgaWYobCA9PSByKQogICAgewogICAgICAgIHN0W25vZGVdICs9IHZhbDsKICAgICAgICByZXR1cm47CiAgICB9CiAgIC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