fun main(args : Array<String>) {
    val (k, t) = readLine()!!.split(" ").map { it.toInt() }
    val aa = readLine()!!.split(" ").map { it.toInt() }

    val max = aa.max()!!
    val rest = aa.sum() - max

    if (rest >= max - 1) {
        println(0)
    } else {
        println((max-1)-rest)
    }
}