class BIT: def __init__(self, n): self.n = n self.data = [0]*(n+1) def to_sum(self, i): s = 0 while i > 0: s += self.data[i] i -= (i & -i) return s def add(self, i, x): while i <= self.n: self.data[i] += x i += (i & -i) def get(self, i, j): return self.to_sum(j)-self.to_sum(i-1) def count_inversion(lists): ans = 0 N = len(lists) tree = BIT(N) for index, p in enumerate(lists): tree.add(p, 1) ans += index+1-tree.to_sum(p) return ans N = int(input()) A = [int(input()) for i in range(N)] ans = count_inversion(A) print(ans)