n = int(eval(input()))

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

ans = 0

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

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

        ans += 1

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

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

ans = 0

for i in range(n - 2):

    if a[i] < a[i + 1] < a[i + 2]:

        ans += 1

    if a[i] > a[i + 1] > a[i + 2]:

        ans += 1

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

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

-for i in range(1, n - 1): -    if a[i - 1] < a[i] < a[i + 1] or a[i - 1] > a[i] > a[i + 1]: +for i in range(n - 2): +    if a[i] < a[i + 1] < a[i + 2]: +        ans += 1 +    if a[i] > a[i + 1] > a[i + 2]: