#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int S, n;
	cin >> S >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	int mx = *max_element(a.begin(), a.end());
	if (mx > (S + 1) / 2) {
		cout << (mx - (S + 1) / 2) * 2 - (S % 2 == 0) << endl;
	} else {
		cout << 0 << endl;
	}
}
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int K, T; cin >> K >> T;
    int a[T]; rep(i, T) cin >> a[i];
    sort(a, a + T, greater<int>());
    int sum = 0;
    rep(i, T - 1)
        sum += a[i + 1];
    cout << ((a[0] - sum - 1 < 0) ? 0 : a[0] - sum - 1) << endl;
}
