from collections import deque N=int(input()) H=list(map(int,input().split())) d=deque([(1<<60,0)]) ans=0 cnt=1 for h in H: while d[0][0]