#!/bin/python import sys def get_vs(m): if len(m) == 1: return {'1': 1}, 1, True lens, _, ordered = get_vs(m[0:len(m)-1]) result = {} ways = 0 for l, v in lens.iteritems(): ways += int(l)*v result[l] = int(l)*v if ordered and m[len(m)-1] >= m[len(m)-2]: ways += 1 result[len(m)] = 1 else: ordered = False return result, ways, ordered n = int(raw_input().strip()) m = map(int, raw_input().strip().split(' ')) _, ways, _ = get_vs(m) print ways