program main
	implicit none
    integer::N,i,ans,r,b,k
    integer, allocatable :: a(:)
    read(*,*) N
    allocate(a(N))
    read(*, *)(a(i), i = 1,N)
    ans=0
	r=0
    b=0
    k=1
    do while(r>=b)
		r=0
        b=0
    	do i=1,N
        	if(a(i)<k) then
            	b=b+1
                r=r
            else 
                b=b
                r=r+1
            end if
       end do
       if(b==r) then 
       	ans=ans+1
       else 
        ans=ans
       end if
       k=k+1
   end do
  print*,ans
 end program main