#BIT
class BinaryIndexedTree():
    def __init__(self, n):
        self.n = 1 << (n.bit_length())
        self.BIT = [0] * (self.n + 1)

    def build(self, init_lis):
        for i, v in enumerate(init_lis):
            self.add(i, v)

    def add(self, i, x):
        i += 1
        while i <= self.n:
            self.BIT[i] += x
            i += i & -i
    
    def sum(self, l, r):
        return self._sum(r) - self._sum(l)

    def _sum(self, i):
        res = 0
        while i > 0:
            res += self.BIT[i]
            i -= i & -i
        return res

    def binary_search(self, x):
        i = self.n
        while True:
            if i & 1:
                if x > self.BIT[i]:
                    i += 1
                break
            if x > self.BIT[i]:
                x -= self.BIT[i]
                i += (i & -i) >> 1
            else:
                i -= (i & -i) >> 1
        return i

n = int(input())
a = [int(input()) for _ in range(n)]
BIT = BinaryIndexedTree(n)
ans = 0
for i in range(n):
    ans += i - BIT._sum(a[i])
    BIT.add(a[i], 1)
print(ans)