
object Main extends App {

  import scala.io.StdIn._
  import scala.math._


  val n = readLine.trim.toInt
  val room = readLine.trim.split(' ').map(_.toInt)
  var stack: List[Int] = List(0)
  var count = 0
  for (length ← room){
    if (stack.head > length){
      stack = stack.dropWhile(len ⇒ len > length)
    }
    if (stack.head != length) {
      count += 1
      stack ::= length
    }
  }
  println(
    count
  )
  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}
