import scala.collection.mutable.ArrayBuffer

object Main extends App {
	val sc = new java.util.Scanner(System.in)
	val pw = new java.io.PrintWriter(System.out)
	
	val n = sc.nextInt
	val p = Array.fill(n)(sc.nextInt)
	val a = Array.fill(n+1)(true)
	
	def f(i: Int, min: Int): Int =
		if (i < 0) 0
		else {
			a(p(i) - 1) = false
			if (p(i) > min) f(i-1, min) else f(i-1, g(min)) + 1
		}
	
	def g(m: Int): Int = if (a(m-1)) m else g(m+1)
	
	pw.println( f(n-1, 1) )
	pw.flush()
}