k,t,*a=list(map(int,open(0).read().split()));print((max([i+i-k-1for i in a]+[0])))
k,t,*a=list(map(int,open(0).read().split()));print((max(max(a)*2-sum(a),1)-1))
k, t, *a = list(map(int, open(0).read().split()))
print((max([i + i - k - 1 for i in a] + [0])))

k, t, *a = list(map(int, open(0).read().split()))
print((max(max(a) * 2 - sum(a), 1) - 1))

-print((max([i + i - k - 1 for i in a] + [0]))) +print((max(max(a) * 2 - sum(a), 1) - 1))