n=int(eval(input()))

#n,k=map(int,input().split())

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

ans=0

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

  b=[a[i-1],a[i],a[i+1]]

  b.sort()

  if b[1]==a[i]:ans+=1

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

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

ans=0

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

  if sorted([p[i-1],p[i],p[i+1]])[1]==p[i]:ans+=1

print(ans)
n = int(eval(input()))
# n,k=map(int,input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
    b = [a[i - 1], a[i], a[i + 1]]
    b.sort()
    if b[1] == a[i]:
        ans += 1
print(ans)

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

-# n,k=map(int,input().split()) -a = list(map(int, input().split())) +p = list(map(int, input().split())) -    b = [a[i - 1], a[i], a[i + 1]] -    b.sort() -    if b[1] == a[i]: +    if sorted([p[i - 1], p[i], p[i + 1]])[1] == p[i]: