program main
  implicit none
  integer i,N,j,now,C(10**5+1),n_C
  !read(*, *) (L(i), i = 1,N)
  !before = 0
  !n_C = 1
  C = -1
  read(*, *) N
  do i = 1,N
    read(*, *) now
    do j = 1,10**5+1
      if (C(j) < now) then
        C(j) = now
        exit
      end if
    end do
  end do
  do i = 1,N+1
    if (c(i) == -1) then
      write(*, *) i-1
      exit
    end if
  end do
end program main
