open Batteries
let n = read_int ()
let a = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ fun a -> a

let rec loop money kabu i =
  if i >= n then money else
  if i >= (n-1) then money + (kabu * a.(i)) else
  if a.(i) < a.(i+1) then loop (money mod a.(i)) (money / a.(i)) (i+1) else
  if a.(i) = a.(i+1) then loop money kabu (i+1) else
  loop (money + kabu * a.(i)) 0 (i+1)

let () = Printf.printf "%d\n" @@ loop 1000 0 0