#include<bits/stdc++.h>
using namespace std;
int k,t,a[105];
int main() {
	ios::sync_with_stdio(false);
	cin >> k >> t;
	for(int i = 1; i <= t; i++)
		cin >> a[i];
	sort(a + 1,a + t + 1);
	if(a[t] <= k / 2)
		cout << "0\n";
	else
		cout << 2 * a[t] - k - 1 << endl;
	return 0;
}