/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#include <fstream>
#define SIZE 100005
#define MOD 1000000007

using namespace std;

class BK {
public:
    static void solve(std::istream& cin, std::ostream& cout) {
      int64_t k, t;
      cin >> k >> t;
      vector<int64_t> vec(t);
      for (int i = 0; i < t; ++i) {
        cin >> vec[i];
      }
      sort(vec.begin(), vec.end());
      int64_t max_vec = vec.back();
      vec.pop_back();
      int64_t sum = accumulate(vec.begin(), vec.end(), 0l);
      cout << max(max_vec - sum - 1, 0l) << endl;
    }
};


int main() {
    BK solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}

#include<iostream>

int main(){
    long long a,b;
    std::cin >> a >> b;
    long long ans = 1e18;
    if(std::abs(a) == std::abs(b)){
       std::cout << 1 << std::endl;
       return 0;
    }
    if(-a < b){
      ans = std::min(ans, a + b + 1);
    }
    if(a < -b){
       ans = std::min(-a - b + 1, ans);
    }
    if(-a < -b){
        ans = std::min(ans,a - b + 2);
    }
    if(a < b){
        ans = std::min(ans, b - a);
    }
    std::cout << ans << std::endl;
}