# encoding: utf-8

import sys

# input = sys.stdin.readline



N = int(eval(input()))

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



ans = 0

for i in range(N - 2):

    pool = [p[i], p[i + 1], p[i + 2]]

    if min(pool) == p[i + 1]:

        continue

    if max(pool) == p[i + 1]:

        continue

    #

    ans += 1



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

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



ans = 0

for i in range(n - 2):

    if p[i] <= p[i + 1] < p[i + 2]:

        ans += 1

    elif p[i + 2] <= p[i + 1] < p[i]:

        ans += 1

    else:

        continue



print(ans)

# encoding: utf-8
import sys

# input = sys.stdin.readline
N = int(eval(input()))
p = list(map(int, input().split()))
ans = 0
for i in range(N - 2):
    pool = [p[i], p[i + 1], p[i + 2]]
    if min(pool) == p[i + 1]:
        continue
    if max(pool) == p[i + 1]:
        continue
    #
    ans += 1
print(ans)

n = int(eval(input()))
p = list(map(int, input().split()))
ans = 0
for i in range(n - 2):
    if p[i] <= p[i + 1] < p[i + 2]:
        ans += 1
    elif p[i + 2] <= p[i + 1] < p[i]:
        ans += 1
    else:
        continue
print(ans)

-# encoding: utf-8 -import sys - -# input = sys.stdin.readline -N = int(eval(input())) +n = int(eval(input())) -for i in range(N - 2): -    pool = [p[i], p[i + 1], p[i + 2]] -    if min(pool) == p[i + 1]: +for i in range(n - 2): +    if p[i] <= p[i + 1] < p[i + 2]: +        ans += 1 +    elif p[i + 2] <= p[i + 1] < p[i]: +        ans += 1 +    else: -    if max(pool) == p[i + 1]: -        continue -    # -    ans += 1