#include<cstdio>
#include<algorithm>
using namespace std;
int n, t, mx;
int main()
{
	scanf("%d%d",&n, &t);
    for(int i = 1; i <= t; ++i)
    {
        int x;
        scanf("%d",&x);
        mx = max(mx, x);
    }
    printf("%d",max(mx - 1 - (n - mx), 0));
} 