class fenwick_tree: def __init__(self, n): self.n = n #x, a1, a2, ..., an self.arr = [0] * (n+1) def add(self, i, x): #1_indexed while i <= self.n: self.arr[i] += x i += i & -i def query(self, i): #a1 + a2 + ... + ai res = 0 while i > 0: res += self.arr[i] i -= i & -i return res N = int(input()) M = [int(input()) for _ in range(N)] ft = fenwick_tree(N) ans = 0 for i in range(N): ans += i - ft.query(M[i]-1) ft.add(M[i], 1) print(ans)