def iskadomatsu(S): return S.index(max(S)) == 1 or S.index(min(S)) == 1 N = int(input()) A = list(map(int, input().split())) Count = 0 for i in range(N - 2): if iskadomatsu([A[i], A[i + 1], A[i + 2]]): Count += 1 print(Count)