program main implicit none integer::N,i,m integer,allocatable::a(:) read *,N allocate(a(N)) read *,a(1:N) m = N do i=N,1,-1 if(a(i).eq.m) then m = m - 1 end if end do print '(i0)', m end program main