import java.io.InputStreamReader
import java.io.BufferedReader

fun main(args: Array<String>) {
  val br = BufferedReader(InputStreamReader(System.`in`))

  val n = br.readLine().toInt()
  val seq = br.readLine().split(" ").map { it.toInt() }.toIntArray()

  tailrec fun rec(acc: Int, pre: Int, i: Int, sign: Int): Int {
    return when {
      i == n -> acc
      pre == seq[i] && sign == 0 -> rec(acc, seq[i], i+1, 0)
      pre < seq[i] && sign == 0 -> rec(acc, seq[i], i+1, 1)
      pre > seq[i] && sign == 0 -> rec(acc, seq[i], i+1, -1)
      pre <= seq[i] && sign > 0 -> rec(acc, seq[i], i+1, 1)
      pre >= seq[i] && sign < 0 -> rec(acc, seq[i], i+1, -1)
      else -> rec(acc+1, seq[i], i+1, 0)
    }
  }

  val ans = rec(1, seq[0], 1, 0)
  println(ans)
}