#coding: utf-8 ##yuki_116 n=int(raw_input()) s=map(int,raw_input().split()) res=0 for i in xrange(len(s)-2): if (s[i+1]>s[i] and s[i+1]>s[i+2]) or (s[i+1]s[i+2] or s[i]