
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt()
  val T = sc.nextLong()

  println(Range(0, n).map(_ => sc.nextLong)
    .foldLeft((0L, -2L * T)) {
      case ((sum, ct), t) => (sum - math.max(T - (t - ct), 0L) + T, t)
    }._1)
}
