

n=int(eval(input()))

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

o=0



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

    if p[i-1]>p[i]>p[i+1] or p[i+1]>p[i]>p[i-1]:

        o+=1

print(o)













n=int(eval(input()))

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

c=0



for i in range(0,n-2):

  

        if p[i]<p[i+1]<p[i+2] or p[i+2]<p[i+1]<p[i]:

            c+=1

print(c)

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

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

-o = 0 -for i in range(1, n - 1): -    if p[i - 1] > p[i] > p[i + 1] or p[i + 1] > p[i] > p[i - 1]: -        o += 1 -print(o) +c = 0 +for i in range(0, n - 2): +    if p[i] < p[i + 1] < p[i + 2] or p[i + 2] < p[i + 1] < p[i]: +        c += 1 +print(c)