__DEUBG__ = 0



import math

import sys



num = int(eval(input()))

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



prev = None

tmp = []

increase = None

count = 0



def dump(x):

    from pprint import pprint

    pprint(x)



#breakpoint()



for x in seq:

    if __DEUBG__:

        print(x)

        print(tmp)

    if prev is None:

        tmp = [x]

    elif increase is True:

        if x >= tmp[-1]:

            tmp.append(x)

        else:

            if __DEUBG__:

                dump(tmp)

            tmp = [x]

            increase = None

            count += 1

    elif increase is False:

        if x <= tmp[-1]:

            tmp.append(x)

        else:

            if __DEUBG__:

                dump(tmp)

            tmp = [x]

            increase = None

            count += 1

    elif increase is None:

        if x == tmp[-1]:

            pass

        elif x > tmp[-1]:

            increase = True

        else:

            increase = False

        tmp.append(x)

    prev = x



if __DEUBG__:

    dump(tmp)



count += 1

print(count)

num = int(eval(input()))

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



prev = None

increase = None

count = 0



prev = seq[0]

for x in seq[1:]:

    if increase is True:

        if x >= prev:

            pass

        else:

            increase = None

            count += 1

    elif increase is False:

        if x <= prev:

            pass

        else:

            increase = None

            count += 1

    elif increase is None:

        if x == prev:

            pass

        elif x > prev:

            increase = True

        else:

            increase = False

    prev = x



count += 1

print(count)

__DEUBG__ = 0
import math
import sys

num = int(eval(input()))
seq = list(map(int, input().split()))
prev = None
tmp = []
increase = None
count = 0


def dump(x):
    from pprint import pprint

    pprint(x)


# breakpoint()
for x in seq:
    if __DEUBG__:
        print(x)
        print(tmp)
    if prev is None:
        tmp = [x]
    elif increase is True:
        if x >= tmp[-1]:
            tmp.append(x)
        else:
            if __DEUBG__:
                dump(tmp)
            tmp = [x]
            increase = None
            count += 1
    elif increase is False:
        if x <= tmp[-1]:
            tmp.append(x)
        else:
            if __DEUBG__:
                dump(tmp)
            tmp = [x]
            increase = None
            count += 1
    elif increase is None:
        if x == tmp[-1]:
            pass
        elif x > tmp[-1]:
            increase = True
        else:
            increase = False
        tmp.append(x)
    prev = x
if __DEUBG__:
    dump(tmp)
count += 1
print(count)

num = int(eval(input()))
seq = list(map(int, input().split()))
prev = None
increase = None
count = 0
prev = seq[0]
for x in seq[1:]:
    if increase is True:
        if x >= prev:
            pass
        else:
            increase = None
            count += 1
    elif increase is False:
        if x <= prev:
            pass
        else:
            increase = None
            count += 1
    elif increase is None:
        if x == prev:
            pass
        elif x > prev:
            increase = True
        else:
            increase = False
    prev = x
count += 1
print(count)

-__DEUBG__ = 0 -import math -import sys - -tmp = [] - - -def dump(x): -    from pprint import pprint - -    pprint(x) - - -# breakpoint() -for x in seq: -    if __DEUBG__: -        print(x) -        print(tmp) -    if prev is None: -        tmp = [x] -    elif increase is True: -        if x >= tmp[-1]: -            tmp.append(x) +prev = seq[0] +for x in seq[1:]: +    if increase is True: +        if x >= prev: +            pass -            if __DEUBG__: -                dump(tmp) -            tmp = [x] -        if x <= tmp[-1]: -            tmp.append(x) +        if x <= prev: +            pass -            if __DEUBG__: -                dump(tmp) -            tmp = [x] -        if x == tmp[-1]: +        if x == prev: -        elif x > tmp[-1]: +        elif x > prev: -        tmp.append(x) -if __DEUBG__: -    dump(tmp)