program answer
  implicit none
  integer :: i, N, sum, ka
  integer, allocatable :: A(:)
  read(*,*) N
  allocate(A(N))
  read(*,*) A

  sum=1000
  ka=0

  do i = 1, N-1
     if(A(i)<=A(i+1)) then
        ka=sum/A(i)
        sum=sum-ka*A(i)
     else
        ka=0
     end if
     sum=sum+ka*A(i+1)
     ka=0
  end do
 write(*,*) sum
  deallocate(A)
  stop
 end program answer
