#include <bits/stdc++.h>
using namespace std;
int main(){
  int K,T;
  int dex;
  int maxv = INT_MIN;
  cin >> K >> T;
  while(T--) {
    cin >> dex;
    maxv = max(maxv,dex);
  }
  cout << max(0,2 * maxv - K - 1) << endl;
  return 0;
}
