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