import java.util.Scanner

import Monotonicity._

object Main extends App {

  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val al = Vector.fill(n)(sc.nextInt)

  val res = loop(al).length
  println(res)


  def loop(list: Vector[Int]): Vector[Vector[Int]] = {
    val (res1, res2, _, _) =
      list.tail.foldLeft( (Vector.empty[Vector[Int]], Vector(list.head), list.head, Monotonicity.Unknown: Monotonicity) ){ case ( (acc , stack, pre, state), now) =>
        if(stack.length == 1) { // stack = Vector(pre) である
          if(pre < now )       (acc, stack :+ now, now, Increasing)
          else if( pre > now)  (acc, stack :+ now, now, Decreasing)
          else                 (acc, stack :+ now, now, Unknown)
        }
        else {
          val booby = stack.init.last
          (booby, pre, now, state) match {
            case (b, p, nw, Increasing) if b <= p && p <= nw => (acc, stack :+ nw, nw, Increasing)
            case (_, _, nw, Increasing)                      => (acc :+ stack, Vector(nw), nw, Unknown)
            case (b, p, nw, Decreasing) if b >= p && p >= nw => (acc, stack :+ nw, nw, Decreasing)
            case (_, _, nw, Decreasing)                      => (acc :+ stack, Vector(nw), nw, Unknown)
            case (b, p, nw, Unknown)    if b <= p && p <= nw => (acc, stack :+ nw, nw, Increasing)
            case (b, p, nw, Unknown)    if b >= p && p >= nw => (acc, stack :+ nw, nw, Decreasing)
            case (b, p, nw, Unknown)                         => (acc, stack :+ nw, nw, Unknown)
          }
        }
      }

    res1 :+ res2
  }
}

sealed trait Monotonicity

object Monotonicity {
  case object Increasing extends Monotonicity
  case object Decreasing extends Monotonicity
  case object Unknown    extends Monotonicity
}
