n = int(eval(input()))

p = input().split()

p = [int(num) for num in p]

t = 0

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

  if ((p[i-1] < p[i] and p[i] < p[i+1])

      or (p[i+1] < p[i] and p[i] < p[i-1])):

    t += 1

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

p = input().split()

p = [int(num) for num in p]

t = 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])):

    t += 1

print(t)
n = int(eval(input()))
p = input().split()
p = [int(num) for num in p]
t = 0
for i in range(1, n - 1):
    if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]):
        t += 1
print(t)

n = int(eval(input()))
p = input().split()
p = [int(num) for num in p]
t = 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]):
        t += 1
print(t)

-    if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]): +    if (p[i - 1] < p[i] < p[i + 1]) or (p[i + 1] < p[i] < p[i - 1]):