#include <iostream>
using namespace std;

int main() {
	long K,T;
	cin >> K >> T;
	
	long a,max=0;
	
for(long i=0; i<T; i++){
	cin >> a;
	if(a>max){max=a;}
}

long kazu=2*max - K -1;
if(kazu>0){cout << kazu << endl;}
else{cout << 0 << endl;}
	return 0;
}