n = int(input()) A = list(map(int, input().split())) c = 0 ans = 0 for i in range(1, n): if A[i - 1] > A[i]: ans += c else: c += 1 print(ans)