Scanf.scanf "%d" @@ fun n ->
  Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0))
  |> Array.fold_left (fun (s, l) x ->
    s + x / 2 + l * (x mod 2), max 0 (x mod 2 - l)) (0, 0)
  |> fst |> Printf.printf "%d\n"