N = int(eval(input()))

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

asc = None

ans = 1

for i in range(N-1):

    d = src[i+1] - src[i]

    if d == 0: continue

    if asc is None:

        asc = d > 0

    elif (asc and d < 0) or (not asc and d > 0):

        ans += 1

        asc = None

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

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



ans = 1

up = None

for a,b in zip(A,A[1:]):

    if a==b: continue

    if a<b:

        if up is None:

            up = True

        elif not up:

            ans += 1

            up = None

    else:

        if up is None:

            up = False

        elif up:

            ans += 1

            up = None

print(ans)
N = int(eval(input()))
src = list(map(int, input().split()))
asc = None
ans = 1
for i in range(N - 1):
    d = src[i + 1] - src[i]
    if d == 0:
        continue
    if asc is None:
        asc = d > 0
    elif (asc and d < 0) or (not asc and d > 0):
        ans += 1
        asc = None
print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
ans = 1
up = None
for a, b in zip(A, A[1:]):
    if a == b:
        continue
    if a < b:
        if up is None:
            up = True
        elif not up:
            ans += 1
            up = None
    else:
        if up is None:
            up = False
        elif up:
            ans += 1
            up = None
print(ans)

-src = list(map(int, input().split())) -asc = None +A = list(map(int, input().split())) -for i in range(N - 1): -    d = src[i + 1] - src[i] -    if d == 0: +up = None +for a, b in zip(A, A[1:]): +    if a == b: -    if asc is None: -        asc = d > 0 -    elif (asc and d < 0) or (not asc and d > 0): -        ans += 1 -        asc = None +    if a < b: +        if up is None: +            up = True +        elif not up: +            ans += 1 +            up = None +    else: +        if up is None: +            up = False +        elif up: +            ans += 1 +            up = None