""" そのまま転倒数 """ def bitadd(a,w,bit): #aにwを加える(1-origin) x = a while x <= (len(bit)-1): bit[x] += w x += x & (-1 * x) def bitsum(a,bit): #ind 1~aまでの和を求める ret = 0 x = a while x > 0: ret += bit[x] x -= x & (-1 * x) return ret N = int(input()) BIT = [0] * (N+10) a = list(map(int,input().split())) ans = 0 for i in range(N): ans += i - bitsum(a[i],BIT) bitadd(a[i],1,BIT) print (ans)