N=int(eval(input()))

temp=input().split()

p=[int(temp[i]) for i in range(N)]



counter=0

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

  if (p[i]-p[i-1])*(p[i]-p[i+1])<0:

    counter+=1

    

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

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



counter=0

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

  if (p[i]-p[i-1])*(p[i]-p[i+1])<0:

    counter+=1

    

print((int(counter)))
N = int(eval(input()))
temp = input().split()
p = [int(temp[i]) for i in range(N)]
counter = 0
for i in range(1, N - 1):
    if (p[i] - p[i - 1]) * (p[i] - p[i + 1]) < 0:
        counter += 1
print(counter)

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

-N = int(eval(input())) -temp = input().split() -p = [int(temp[i]) for i in range(N)] +n = int(eval(input())) +p = list(map(int, input().split())) -for i in range(1, N - 1): +for i in range(1, n - 1): -print(counter) +print((int(counter)))