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