N = int(eval(input()))

P = [int(i) for i in input().split()]



cnt = 0

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

    A = [P[i - 1], P[i], P[i + 1]]

    maxA = max(A)

    minA = min(A)

    if P[i] != maxA and P[i] != minA:

        cnt += 1

        

print(cnt)
n = int(eval(input()))

P = [int(i) for i in input().split()]



ans = 0

for i in range(1, n - 1):

    if P[i] != max(P[i - 1], P[i], P[i + 1]) and P[i] != min(P[i - 1], P[i], P[i + 1]):

        ans += 1

        

print(ans)
N = int(eval(input()))
P = [int(i) for i in input().split()]
cnt = 0
for i in range(1, N - 1):
    A = [P[i - 1], P[i], P[i + 1]]
    maxA = max(A)
    minA = min(A)
    if P[i] != maxA and P[i] != minA:
        cnt += 1
print(cnt)

n = int(eval(input()))
P = [int(i) for i in input().split()]
ans = 0
for i in range(1, n - 1):
    if P[i] != max(P[i - 1], P[i], P[i + 1]) and P[i] != min(P[i - 1], P[i], P[i + 1]):
        ans += 1
print(ans)

-N = int(eval(input())) +n = int(eval(input())) -cnt = 0 -for i in range(1, N - 1): -    A = [P[i - 1], P[i], P[i + 1]] -    maxA = max(A) -    minA = min(A) -    if P[i] != maxA and P[i] != minA: -        cnt += 1 -print(cnt) +ans = 0 +for i in range(1, n - 1): +    if P[i] != max(P[i - 1], P[i], P[i + 1]) and P[i] != min(P[i - 1], P[i], P[i + 1]): +        ans += 1 +print(ans)