import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List

main = do
  BS.getLine
  li <- BS.getLine
  let as = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  let ans = compute as
  print ans

compute :: [Int] -> Int
compute as = toBuy 1000 as

toBuy m (a1:a2:as)
  | a1 >= a2 = toBuy m (a2:as)
  | True = let (p,q) = divMod m a1 in toSell q p (a2:as)
toBuy m _ = m

toSell m k (a1:a2:as)
  | a1 <= a2 = toSell m k (a2:as)
  | True = toBuy (m + a1 * k) (a2:as)
toSell m k [a] = m + a * k

-- 少しでも上がるなら全力買い、下がるなら全力売りを繰り返す。下りのところは無視する。
