N = int(eval(input()))

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

cnt = 0



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

    if p[i] > p[i -1] and p[i] < p[i + 1]:

        cnt += 1

    elif p[i] < p[i - 1] and p[i] > p[i + 1]:

        cnt += 1



print(cnt)

n = int(eval(input()))

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

ans = 0

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

    if p[i - 1] > p[i] and p[i] > p[i + 1]:

        ans += 1

    if p[i - 1] < p[i] and p[i] < p[i + 1]:

        ans += 1

print(ans)

    
N = int(eval(input()))
p = list(map(int, input().split()))
cnt = 0
for i in range(1, N - 1):
    if p[i] > p[i - 1] and p[i] < p[i + 1]:
        cnt += 1
    elif p[i] < p[i - 1] and p[i] > p[i + 1]:
        cnt += 1
print(cnt)

n = int(eval(input()))
p = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
    if p[i - 1] > p[i] and p[i] > p[i + 1]:
        ans += 1
    if p[i - 1] < p[i] and 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): -    if p[i] > p[i - 1] and p[i] < p[i + 1]: -        cnt += 1 -    elif p[i] < p[i - 1] and p[i] > p[i + 1]: -        cnt += 1 -print(cnt) +ans = 0 +for i in range(1, n - 1): +    if p[i - 1] > p[i] and p[i] > p[i + 1]: +        ans += 1 +    if p[i - 1] < p[i] and p[i] < p[i + 1]: +        ans += 1 +print(ans)