#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int k,t,i,a,max=0,s=0;
  cin >> k >> t;
  for (i=0;i<t;i++){
    cin >> a;
    s+=a;
    if (max<a) max=a;
  }
  s-=max;
  if (max-1>=s) cout << max-1-s << endl;
  else cout << 0 << endl;
  return 0;
}