
fun main(args:Array<String>):Unit {
    val (n, k) = readLine()!!.trim().split(' ').map(String::toInt)
    val time = Array(n){readLine()!!.trim().toLong()}
    val diff = Array(n - 1){time[it + 1] - time[it] - 1}.sortedDescending()
    println(
            time.last() - time[0] - diff.take(k - 1).sum() + 1
    )
}
