object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val p = List.fill(n)(sc.nextInt)
  val zippedP = p.zipWithIndex

  def go (l: List[(Int, Int)], acc: Int): Int = l match {
    case Nil => acc
    case h::t if h._2 > p.indexWhere(h._1 >= _) => go(t, acc)
    case h::t => go(t, acc + 1)
  }
  println(go(zippedP, 0))
}