import copy

import numpy as np



S = eval(input())



N = int(S)



S = eval(input())



P = list(map(int, S.split()))



check = []



count = 0



for i in range(0, N-2, 1):



    check = P[i:i+3]

    check = np.array(check)

    check = check.argsort()

    if check[1] == 1:

        count = count + 1



print(count)

n = int(eval(input()))

P = list(map(int, input().split()))

count = 0

for i in range(n-2):



    P_temp = [P[i], P[i+1], P[i+2]]

    P_temp.sort()

    if P_temp[1] == P[i+1]:

        count = count + 1



print(count)

import copy
import numpy as np

S = eval(input())
N = int(S)
S = eval(input())
P = list(map(int, S.split()))
check = []
count = 0
for i in range(0, N - 2, 1):
    check = P[i : i + 3]
    check = np.array(check)
    check = check.argsort()
    if check[1] == 1:
        count = count + 1
print(count)

n = int(eval(input()))
P = list(map(int, input().split()))
count = 0
for i in range(n - 2):
    P_temp = [P[i], P[i + 1], P[i + 2]]
    P_temp.sort()
    if P_temp[1] == P[i + 1]:
        count = count + 1
print(count)

-import copy -import numpy as np - -S = eval(input()) -N = int(S) -S = eval(input()) -P = list(map(int, S.split())) -check = [] +n = int(eval(input())) +P = list(map(int, input().split())) -for i in range(0, N - 2, 1): -    check = P[i : i + 3] -    check = np.array(check) -    check = check.argsort() -    if check[1] == 1: +for i in range(n - 2): +    P_temp = [P[i], P[i + 1], P[i + 2]] +    P_temp.sort() +    if P_temp[1] == P[i + 1]: