n = int(eval(input()))

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



count = 0

for i in range(1,len(p)-1,1):

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

        count = count +1

    elif p[i+1] < p[i] < p[i-1]:

        count = count +1

    else:

        pass



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

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



count = 0

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

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

        count = count +1

    elif p[i+1] < p[i] < p[i-1]:

        count = count +1

    else:

        pass



print(count)
n = int(eval(input()))
p = list(map(int, input().split()))
count = 0
for i in range(1, len(p) - 1, 1):
    if p[i + 1] > p[i] > p[i - 1]:
        count = count + 1
    elif p[i + 1] < p[i] < p[i - 1]:
        count = count + 1
    else:
        pass
print(count)

n = int(eval(input()))
p = list(map(int, input().split()))
count = 0
for i in range(1, n - 1, 1):
    if p[i + 1] > p[i] > p[i - 1]:
        count = count + 1
    elif p[i + 1] < p[i] < p[i - 1]:
        count = count + 1
    else:
        pass
print(count)

-for i in range(1, len(p) - 1, 1): +for i in range(1, n - 1, 1):