import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    as <- getIntList
    let gs = reverse $ (\(a,c,x) -> (a,c) : x) $ f as
    let ans = foldl' h 1000 gs
    print ans

f (a:as) = foldl' g (a,a,[]) as
    where g (a,b,s) c | b <= c = (a,c,s)
                      | otherwise = (c,c, (a,b) : s)

h m (a,b) = m'
    where (k,l) = m `divMod` a
          m' = l + k * b