      PROGRAM RoadToMillionair
      IMPLICIT NONE
      INTEGER,PARAMETER :: p = 16
      integer(p) :: n,yen,kabu, i,mi
      integer(p),allocatable :: a(:)
      logical,allocatable :: isPeak(:)
      
      read*,n
      allocate( a(n+1),isPeak(n) )
      read*,a(1:n)
      a(n+1) = 100
      
      isPeak = .false.
      do i = 2,n
        if( a(i-1)<=a(i) .and. a(i)>a(i+1) )then
          isPeak(i) = .true.
        end if
      end do
      
      
      yen = 1000
      kabu = 0
      mi = a(1)
      do i = 1,n
        if( isPeak(i) )then
          !売り
          kabu = yen / mi
          yen = yen - mi*kabu
          
          !買い
          yen = yen + kabu*a(i)
          kabu = 0
          
          mi = a(i+1)
          
          
        else
          mi = min( a(i),mi )
        end if
      end do
      
      
      print*,yen
      
      stop
      !debugg
      print*,''
      print*,n
      print*,a
      print*,isPeak
      
      
      END PROGRAM