let () = Scanf.scanf "%d\n" @@ fun n ->
  let hs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun h -> h in
  Printf.printf "%d\n" @@ Array.fold_left ( + ) hs.(0) @@
  Array.init (n - 1) @@ fun i -> max 0 @@ hs.(i + 1) - hs.(i)

