program main

  implicit none

  integer    :: n, m
  integer,allocatable :: p(:), nn(:)

  integer    :: i,j,k
  
  read(*,*) n
  allocate( p(n) )
  allocate( nn(n) )
  read(*,*) p
  
  do i = 1, n  
    nn(p(i)) = i 
  end do
  
  m = 0
  do i = 1, n  
    do j = 1, nn(i) 
      if( p(j) >= i ) then
      else
        m = m - 1
        exit
      end if
    end do
    m = m + 1
  end do
  print*,m
  
end program main
