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