#include<iostream>
#include<algorithm>

using namespace std;

int main(void)
{
	int k,t;
	cin >> k >> t;
	int a[105];
	for(int i=1;i<=t;i++)
		cin >> a[i-1];
	
	sort(a,a+t);

	int x=a[t-1];
	
	cout << (x<(k+1)/2 ? 0:k-(k-x)*2-1) << endl;
}