#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll K,T; cin>>K>>T;
    vector<ll> A(T,0);
    rep(i,T){
        cin>>A[i];
    }
    sort(all(A));
    ll L=A[sz(A)-1];
    rep(i,sz(A)-1){
        L-=A[i];
    }
    cout<<max(L-1,0ll)<<endl;
}


#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int k, t;
  cin >> k >> t;

  priority_queue<int> pq;
  rep(i, 0, t) {
    int a;
    cin >> a;
    pq.push(a);
  }

  int ans = 0;
  bool is_first = true, flg = false;
  rep(i, 0, k) {
    if (flg)
      ans++;
    if (pq.size() == 1)
      flg = true;

    if (is_first) {
      int a = pq.top();
      pq.pop();
      a--;
      if (a)
        pq.push(a);
    } else {
      int a = pq.top();
      pq.pop();
      if (!pq.empty()) {
        int b = pq.top();
        pq.pop();
        b--;
        if (b)
          pq.push(b);
      }
      pq.push(a);
    }
    is_first = !is_first;
  }

  cout << ans << endl;
}
