N = int(eval(input()))

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



ans = 0

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

    if ps[i-1] < ps[i] < ps[i+1] or ps[i-1] > ps[i] > ps[i+1]:

        ans += 1



print(ans)

N = int(eval(input()))

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



ans = 0

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

    if Ps[i-1]<Ps[i]<Ps[i+1] or Ps[i-1]>Ps[i]>Ps[i+1]:

        ans += 1



print(ans)

N = int(eval(input()))
ps = list(map(int, input().split()))
ans = 0
for i in range(1, N - 1):
    if ps[i - 1] < ps[i] < ps[i + 1] or ps[i - 1] > ps[i] > ps[i + 1]:
        ans += 1
print(ans)

N = int(eval(input()))
Ps = list(map(int, input().split()))
ans = 0
for i in range(1, N - 1):
    if Ps[i - 1] < Ps[i] < Ps[i + 1] or Ps[i - 1] > Ps[i] > Ps[i + 1]:
        ans += 1
print(ans)

-ps = list(map(int, input().split())) +Ps = list(map(int, input().split())) -    if ps[i - 1] < ps[i] < ps[i + 1] or ps[i - 1] > ps[i] > ps[i + 1]: +    if Ps[i - 1] < Ps[i] < Ps[i + 1] or Ps[i - 1] > Ps[i] > Ps[i + 1]: