n = int(input())
height = [int(x) for x in input().split()]
result = 0.0
for h in range(1, n-1):
if height[h] < height[h + 1] and height[h] < height[h - 1]:
result += 1
elif height[h] == height[h + 1]:
if height[h] < height[h - 1]:
result += 0.5
elif height[h] == height[h - 1]:
if height[h] < height[h + 1]:
result += 0.5
print(int(result))