N=int(input()) S=list(map(int,input().split())) c=0 for i in range(len(S)-2): if S[i]!=S[i+2]: if S[i]S[i+2] or S[i]>S[i+1]