open Batteries
let () =
  let n,t = Scanf.scanf "%d %d " (fun a b -> a,b) in
  let t_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in

  let rec aux prev l =
    match l with
    | [] -> []
    | hd :: tl -> (hd - prev) :: (aux hd tl)
  in
  let l = aux 0 t_lst in
  let res = t + List.fold_left (fun x y -> x + (if y < t then y else t)) 0 l in
  Printf.printf "%d\n" res

