fun main(args: Array<String>) {
    val (n, t) = readLine()!!.split(' ').map(String::toInt)
    val a = readLine()!!.split(' ').map(String::toInt)
    var blank = 0
    for (i in 1 until a.size) {
        val interval = a[i] - a[i - 1]
        if (t < interval) {
            blank += interval - t
        }
    }
    println(a.last() + t  - blank)
}
