#B

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()))

count = 0

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

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

        count += 1

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

        count += 1

    else:

        pass



print(count)
# B
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()))
count = 0
for i in range(1, n - 1):
    if p[i - 1] < p[i] and p[i] < p[i + 1]:
        count += 1
    elif p[i - 1] > p[i] and p[i] > p[i + 1]:
        count += 1
    else:
        pass
print(count)

-# B -ans = 0 +count = 0 -        ans += 1 -    if p[i - 1] > p[i] and p[i] > p[i + 1]: -        ans += 1 -print(ans) +        count += 1 +    elif p[i - 1] > p[i] and p[i] > p[i + 1]: +        count += 1 +    else: +        pass +print(count)