from sys import stdin from bisect import bisect, bisect_left class BIT: def __init__(self, n): self.size = n self.bit = [0] * (n + 1) def add(self, i, x): 'add c to the value at index i' while i <= self.size: self.bit[i] += x i += i & -i def sum(self, i): 'get sum from the start to the index of i' ret = 0 while i > 0: ret += self.bit[i] i -= i & -i return ret def range_sum(self, start, end): 'Calculate a[start], a[start+1], ... a[end]' return self.sum(end) - self.sum(start - 1) def __str__(self): return str(self.bit) def main(): N = int(input()) A = list(map(int, stdin.read().splitlines())) ans = 0 bit = BIT(N) for i, v in enumerate(A): ans += i - bit.sum(v) bit.add(v, 1) print(ans) num = sorted(A) for i in range(N - 1): ans -= bisect_left(num, A[i]) ans += N - bisect(num, A[i]) print(ans) main()