let k, t = Scanf.scanf " %d %d" @@ fun a b -> a, b
let a_s = Array.init t @@ fun _ -> Scanf.scanf " %d" (+) 0
let m, s = Array.(fold_left max a_s.(0) a_s, fold_left (+) 0 a_s)
let _ = Printf.printf "%d\n" @@ max 0 @@ 2 * m - s - 1