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())) if N == 1: print(0) return cnt = 0 ans = [] apnd = ans.append bit = BIT(N) a = sorted(set(A)) for i, v in enumerate(A): x = bisect(a, v) cnt += i - bit.sum(x) bit.add(x, 1) apnd(cnt) num = sorted(A) for i in range(N - 1): cnt -= bisect_left(num, A[i]) cnt += N - bisect(num, A[i]) apnd(cnt) print(*ans, sep='\n') main()