cnt = 0

n = int(eval(input()))

lst = [int(i) for i in input().split()]

for i in range(n-2):

    a,b,c = lst[i],lst[i+1],lst[i+2]

    if (a<b and b<c) or (c<b and b<a):

        cnt += 1

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

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

cnt = 0

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

    x,y,z = lst[i-1],lst[i],lst[i+1]

    if x<=y<=z or z<=y<=x:

        cnt += 1

print(cnt)
cnt = 0
n = int(eval(input()))
lst = [int(i) for i in input().split()]
for i in range(n - 2):
    a, b, c = lst[i], lst[i + 1], lst[i + 2]
    if (a < b and b < c) or (c < b and b < a):
        cnt += 1
print(cnt)

n = int(eval(input()))
lst = list(map(int, input().split()))
cnt = 0
for i in range(1, n - 1):
    x, y, z = lst[i - 1], lst[i], lst[i + 1]
    if x <= y <= z or z <= y <= x:
        cnt += 1
print(cnt)

+n = int(eval(input())) +lst = list(map(int, input().split())) -n = int(eval(input())) -lst = [int(i) for i in input().split()] -for i in range(n - 2): -    a, b, c = lst[i], lst[i + 1], lst[i + 2] -    if (a < b and b < c) or (c < b and b < a): +for i in range(1, n - 1): +    x, y, z = lst[i - 1], lst[i], lst[i + 1] +    if x <= y <= z or z <= y <= x: