import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	int k, t;
	{
		int[] tmp = readln.chomp.split.map!(to!int).array;
		k = tmp[0], t = tmp[1];
		}
	
	int[] as = readln.chomp.split.map!(to!int).array;
	
	int amax = as.reduce!("max(a,b)");
	
	int ans;
	
	if(k % 2 == 0){
		if(amax <= k / 2) ans = 0;
		else ans = (amax - (k / 2)) * 2 - 1;
		}
	else{
		if(amax <= (k + 1) / 2) ans = 0;
		else ans = (amax - ((k + 1) / 2)) * 2;
		}
	
	ans.writeln;
	
	}
	