N = int(eval(input()))

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

def solve(N,A):

    ans = 1

    lis = [A[0]]

    for i in range(1,N):

        if len(lis)==1 or diff==0:

            diff = A[i]-A[i-1]

        elif (A[i]-A[i-1])*diff<0:

            ans += 1

            lis = []

        lis.append(A[i])

    return ans

print((solve(N,A)))
def check(a,b):

  if a<b:

    return 'up'

  if a>b:

    return 'down'

  return ''



def solve():

  ans = 1

  N = int(eval(input()))

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

  ud = ''

  for i in range(N-1):

    a = check(A[i],A[i+1])

    if ud=='' or ud==a:

      ud = a

      continue

    if a=='':

      continue

    ans += 1

    ud = ''

  return ans

print((solve()))
N = int(eval(input()))
A = list(map(int, input().split()))


def solve(N, A):
    ans = 1
    lis = [A[0]]
    for i in range(1, N):
        if len(lis) == 1 or diff == 0:
            diff = A[i] - A[i - 1]
        elif (A[i] - A[i - 1]) * diff < 0:
            ans += 1
            lis = []
        lis.append(A[i])
    return ans


print((solve(N, A)))

def check(a, b):
    if a < b:
        return "up"
    if a > b:
        return "down"
    return ""


def solve():
    ans = 1
    N = int(eval(input()))
    A = list(map(int, input().split()))
    ud = ""
    for i in range(N - 1):
        a = check(A[i], A[i + 1])
        if ud == "" or ud == a:
            ud = a
            continue
        if a == "":
            continue
        ans += 1
        ud = ""
    return ans


print((solve()))

-N = int(eval(input())) -A = list(map(int, input().split())) +def check(a, b): +    if a < b: +        return "up" +    if a > b: +        return "down" +    return "" -def solve(N, A): +def solve(): -    lis = [A[0]] -    for i in range(1, N): -        if len(lis) == 1 or diff == 0: -            diff = A[i] - A[i - 1] -        elif (A[i] - A[i - 1]) * diff < 0: -            ans += 1 -            lis = [] -        lis.append(A[i]) +    N = int(eval(input())) +    A = list(map(int, input().split())) +    ud = "" +    for i in range(N - 1): +        a = check(A[i], A[i + 1]) +        if ud == "" or ud == a: +            ud = a +            continue +        if a == "": +            continue +        ans += 1 +        ud = "" -print((solve(N, A))) +print((solve()))