let () = Scanf.scanf "%d %d\n" @@ fun n t ->
    read_line ()
    |> Str.split (Str.regexp "[ \t]+")
    |> List.rev_map int_of_string
    |> List.rev
    |> List.fold_left (fun (t1, sum) t2 -> (t2, sum + min (t2 - t1) t)) (0, t)
    |> function (_, sum) -> sum
    |> Printf.printf "%d"
