mod = 998244353 def main(): import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) B = [] for i in range(N - 1): if A[i+1] > A[i]: B.append(1) else: B.append(0) ans = 0 cnt_1 = 0 for b in B: if b == 0: ans += cnt_1 else: cnt_1 += 1 print(ans) if __name__ == '__main__': main()