function Main(input) {
  var input = input.split("\n");
  var K = parseInt(input[0].split(" ")[0]);
  var T = parseInt(input[0].split(" ")[1]);
  var a = input[1].split(" ").map((el)=>{
    return parseInt(el);
  });
  var max = a.reduce( function (previous, current) {
  	return previous > current ? previous:current;
  });
  if(max > 0){
    console.log(max-1-(K-max));
  }else{
    console.log(0);
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));