n=int(eval(input()))

 

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

 

count = 0

 

for i in range(n-2):

    if t[i] <= t[i+1] and t[i+1] <= t[i+2] or t[i] >= t[i+1] and t[i+1] >= t[i+2]:

        count += 1

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



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



ans = 0



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

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

        ans += 1

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

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

-count = 0 -for i in range(n - 2): -    if ( -        t[i] <= t[i + 1] -        and t[i + 1] <= t[i + 2] -        or t[i] >= t[i + 1] -        and t[i + 1] >= t[i + 2] -    ): -        count += 1 -print(count) +ans = 0 +for i in range(1, n - 1): +    if t[i - 1] < t[i] < t[i + 1] or t[i - 1] > t[i] > t[i + 1]: +        ans += 1 +print(ans)