满分答案:
n = int(input())
price = [0 for i in range(n)]
price = input().split()
num = 0
for i in range(n):
price[i] = int(price[i])
for i in range(n-2):
if price[i] > price[i+1] and price[i+1] < price[i+2]:
num = num +1
if price[i] < price[i+1] and price[i+1] > price[i+2]:
num = num +1
print(num)