#include <iostream>
using namespace std;
int main(){
  int K, T;
  cin >> K >> T;
  int A[T];
  for(int i = 0; i < T; ++i) cin >> A[i];
  int M = 1, m = 0;
  for(int i = 0; i < T; ++i){
    M = max(M,A[i]);
  }
  if(M <= (K+1)/2) cout << 0 << endl;
  else cout << M - (K-M+1) << endl;
  return 0;
}
