n = int(input()) list1 = list(map(int,input().split())) num = 0 for i in range(1, n-1): if (list1[i-1] > list1[i] and (list1[i+1] > list1[i])) or\ (list1[i-1] < list1[i] and (list1[i+1] < list1[i])): num = num + 1 print(num)
n = int(input()) list1 = list(map(int,input().split())) num = 0 for i in range(1, n-1): if (list1[i-1] > list1[i] and (list1[i+1] > list1[i])) or\ (list1[i-1] < list1[i] and (list1[i+1] < list1[i])): num = num + 1 print(num)