let words s = let r = Str.regexp " +" in Str.split r s let min_num_of_ops n xs = let rec mnoo t = function [] -> t | y :: ys -> match y with t -> mnoo (t - 1) ys | _ -> mnoo t ys in mnoo n (List.rev xs) let () = let n = read_int () in let xs = List.map int_of_string (words (read_line ())) in let ans = min_num_of_ops n xs in print_int ans