n = int(eval(input()))

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



cnt = 0

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

    if (p[i - 1] < p[i] < p[i + 1]) or (p[i - 1] > p[i] > p[i + 1]):

        cnt += 1

print(cnt)

n = int(eval(input()))

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



print((len(tuple(

    [x for x in zip(p, p[1:], p[2:]) if (x[0] < x[1] < x[2]) or (x[0] > x[1] > x[2])]

))))

n = int(eval(input()))
p = tuple(map(int, input().split()))
cnt = 0
for i in range(1, n - 2 + 1):
    if (p[i - 1] < p[i] < p[i + 1]) or (p[i - 1] > p[i] > p[i + 1]):
        cnt += 1
print(cnt)

n = int(eval(input()))
p = tuple(map(int, input().split()))
print(
    (
        len(
            tuple(
                [
                    x
                    for x in zip(p, p[1:], p[2:])
                    if (x[0] < x[1] < x[2]) or (x[0] > x[1] > x[2])
                ]
            )
        )
    )
)

-cnt = 0 -for i in range(1, n - 2 + 1): -    if (p[i - 1] < p[i] < p[i + 1]) or (p[i - 1] > p[i] > p[i + 1]): -        cnt += 1 -print(cnt) +print( +    ( +        len( +            tuple( +                [ +                    x +                    for x in zip(p, p[1:], p[2:]) +                    if (x[0] < x[1] < x[2]) or (x[0] > x[1] > x[2]) +                ] +            ) +        ) +    ) +)