n = int(eval(input()))

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

print((sum(l[i]<l[i+1]<l[i+2] or l[i]>l[i+1]>l[i+2] for i in range(n-2))))
n=int(eval(input()))

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

a=0

for i in range(n-2):

  p,q,r=l[i:i+3]

  if p<q<r or r<q<p: a+=1

print(a)
n = int(eval(input()))
l = list(map(int, input().split()))
print(
    (
        sum(
            l[i] < l[i + 1] < l[i + 2] or l[i] > l[i + 1] > l[i + 2]
            for i in range(n - 2)
        )
    )
)

n = int(eval(input()))
l = list(map(int, input().split()))
a = 0
for i in range(n - 2):
    p, q, r = l[i : i + 3]
    if p < q < r or r < q < p:
        a += 1
print(a)

-print( -    ( -        sum( -            l[i] < l[i + 1] < l[i + 2] or l[i] > l[i + 1] > l[i + 2] -            for i in range(n - 2) -        ) -    ) -) +a = 0 +for i in range(n - 2): +    p, q, r = l[i : i + 3] +    if p < q < r or r < q < p: +        a += 1 +print(a)