from sys import stdin from bisect import bisect, bisect_left class BIT: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def add(self, i, x): while i <= self.size: self.tree[i] += x i += i & -i def sum(self, i): ret = 0 while i > 0: ret += self.tree[i] i -= i & -i return ret def main(): N = int(input()) A = list(map(int, stdin.read().splitlines())) ans = [0] * N bit = BIT(N) num = sorted(set(A)) for i, v in enumerate(A): x = bisect(num, v) ans[0] += i - bit.sum(x) bit.add(x, 1) num = sorted(A) for i in range(1, N): ans[i] = ans[i-1] - bisect_left(num, A[i-1]) ans[i] += N - bisect(num, A[i-1]) print(*ans, sep='\n') main()