a=int(input()) b=[int(i) for i in input().split()] c=0 for i in range(2,a): if (b[i-1]>b[i]) and (b[i-1]>b[i-2]) or (b[i-1]