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 up is None:

        up = a<b

    elif up:

        if a>b:

            up = None

            ans += 1

    else:

        if a<b:

            up = None

            ans += 1

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

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



ans = 1

up = down = False

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

    if a<b:

        if down:

            ans += 1

            up = down = False

        else:

            up = True

            down = False

    elif a>b:

        if up:

            ans += 1

            up = down = False

        else:

            up = False

            down = True

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 up is None:
        up = a < b
    elif up:
        if a > b:
            up = None
            ans += 1
    else:
        if a < b:
            up = None
            ans += 1
print(ans)

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

-up = None +up = down = False -    if a == b: -        continue -    if up is None: -        up = a < b -    elif up: -        if a > b: -            up = None +    if a < b: +        if down: -    else: -        if a < b: -            up = None +            up = down = False +        else: +            up = True +            down = False +    elif a > b: +        if up: +            up = down = False +        else: +            up = False +            down = True