Scanf.scanf "%d %d" (fun n d -> let a = Array.init n (fun i -> if i = 0 then 0 else Scanf.scanf " %d" (fun a -> a)) in let b = Array.make n 0 in for i = 1 to n - 1 do a.(i) <- a.(i) + a.(i - 1); b.(i) <- max a.(i) (b.(i - 1) + d) done; Printf.printf "0"; for i = 1 to n - 1 do Printf.printf " %d" b.(i) done; print_newline () )