open Printf
open Scanf
open Base
open Stdio

(* Core.read_line is deprecated *)
let read_line () =
    (* Out_channel.(flush stdout); *)
    In_channel.(input_line_exn stdin)

let f = let rec loop l (money, kabu) = match l with
            | [] -> failwith ""
            | [x] -> money + kabu * x
            | (x::(y::_ as y_s)) -> let maisu = money / x in
                loop y_s (if x > y
                    then (money + kabu * x, 0)
                    else (money - maisu * x, kabu + maisu)
                )
    in
    Fn.flip loop (1000, 0)

let () =
    ignore (read_line ());
    read_line ()
    |> String.split_on_chars ~on:[' ']
    |> List.map ~f:int_of_string
    |> f
    |> printf "%d\n"
