let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let lst = Array.to_list (Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d) in
  let (bfr,(x,ans)) = List.fold_left
      (fun (bfr,(stock, money)) x ->
         if bfr < x then (x,(stock+(money/bfr), money - bfr*(money/bfr)))
         else (x, (0, money+bfr*stock))) (List.hd lst, (0, 1000)) (List.tl lst) in
  Printf.printf "%d\n" (bfr*x+ans)