# AGC013A - Sorted Arrays

def main():

    n = int(eval(input()))

    A = tuple(map(int, input().rstrip().split()))



    # compress continuous parts of same numbers (e.g. 111 -> 1)

    B, cur = [], 0

    for i in A:

        if i != cur:

            B += [i]

            cur = i

    B += [0]



    # check the modified sequence

    ans, cur = 0, B[0]

    flg = B[0] < B[1]  # increasing (1) / decreasing (0)

    for i, j in enumerate(B[1:-1], start=1):

        if (flg and j < cur) or (not flg and j > cur):

            ans += 1

            flg = B[i] < B[i + 1]

        cur = j

    print((ans + 1))





if __name__ == "__main__":

    main()
# AGC013A - Sorted Arrays

def main():

    n = int(eval(input()))

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

    ans, cur = 0, A[0]

    flg = 0  # unknown (0), increasing (1), decreasing (2)

    for i in A:

        if (flg == 1 and i < cur) or (flg == 2 and i > cur):  # end of trend

            ans += 1

            flg = 0

        elif not flg and cur < i:  # new increasing trend

            flg = 1

        elif not flg and cur > i:  # new decreasing trend

            flg = 2

        cur = i

    print((ans + 1))





if __name__ == "__main__":

    main()
# AGC013A - Sorted Arrays
def main():
    n = int(eval(input()))
    A = tuple(map(int, input().rstrip().split()))
    # compress continuous parts of same numbers (e.g. 111 -> 1)
    B, cur = [], 0
    for i in A:
        if i != cur:
            B += [i]
            cur = i
    B += [0]
    # check the modified sequence
    ans, cur = 0, B[0]
    flg = B[0] < B[1]  # increasing (1) / decreasing (0)
    for i, j in enumerate(B[1:-1], start=1):
        if (flg and j < cur) or (not flg and j > cur):
            ans += 1
            flg = B[i] < B[i + 1]
        cur = j
    print((ans + 1))


if __name__ == "__main__":
    main()

# AGC013A - Sorted Arrays
def main():
    n = int(eval(input()))
    A = tuple(map(int, input().split()))
    ans, cur = 0, A[0]
    flg = 0  # unknown (0), increasing (1), decreasing (2)
    for i in A:
        if (flg == 1 and i < cur) or (flg == 2 and i > cur):  # end of trend
            ans += 1
            flg = 0
        elif not flg and cur < i:  # new increasing trend
            flg = 1
        elif not flg and cur > i:  # new decreasing trend
            flg = 2
        cur = i
    print((ans + 1))


if __name__ == "__main__":
    main()

-    A = tuple(map(int, input().rstrip().split())) -    # compress continuous parts of same numbers (e.g. 111 -> 1) -    B, cur = [], 0 +    A = tuple(map(int, input().split())) +    ans, cur = 0, A[0] +    flg = 0  # unknown (0), increasing (1), decreasing (2) -        if i != cur: -            B += [i] -            cur = i -    B += [0] -    # check the modified sequence -    ans, cur = 0, B[0] -    flg = B[0] < B[1]  # increasing (1) / decreasing (0) -    for i, j in enumerate(B[1:-1], start=1): -        if (flg and j < cur) or (not flg and j > cur): +        if (flg == 1 and i < cur) or (flg == 2 and i > cur):  # end of trend -            flg = B[i] < B[i + 1] -        cur = j +            flg = 0 +        elif not flg and cur < i:  # new increasing trend +            flg = 1 +        elif not flg and cur > i:  # new decreasing trend +            flg = 2 +        cur = i