fun main(args: Array<String>) {
    codefestival2017qualc_b()
}

fun codefestival2017qualc_b() {
    val (k, t) = readLine()!!.split(" ").map { it.toInt() }
    val aList = readLine()!!.split(" ").map { it.toInt() }
        .sorted()

    val max = aList.last()
    val exceptMaxSum = aList.dropLast(1).sum()

    val answer = Math.max(0, max - exceptMaxSum - 1)

    println(answer)
}
