#include <bits/stdc++.h>
using namespace std;

int main() {
  int k,t,amax=0;cin>>k>>t;
  vector<int> a(t);
  for(int i=0;i<t;i++){
    cin>>a[i];
    amax=max(a[i],amax);
  }
  cout<<((2*amax-1-k)<0?0:(2*amax-1-k))<<endl;
}