K,T = list(map(int,input().split()))

A = sorted(list(map(int,input().split())),reverse=True)

a = A[0]

if a<=(K+1)//2:

    ans = 0

elif K%2==1:

    ans = (a-(K+1)//2)*2

else:

    ans = (a-(K+1)//2)*2-1

print(ans)
K,T = list(map(int,input().split()))

A = list(map(int,input().split()))

a = max(A)

if a<=(K+1)//2:

    print((0))

else:

    print((2*a-K-1))
K, T = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)
a = A[0]
if a <= (K + 1) // 2:
    ans = 0
elif K % 2 == 1:
    ans = (a - (K + 1) // 2) * 2
else:
    ans = (a - (K + 1) // 2) * 2 - 1
print(ans)

K, T = list(map(int, input().split()))
A = list(map(int, input().split()))
a = max(A)
if a <= (K + 1) // 2:
    print((0))
else:
    print((2 * a - K - 1))

-A = sorted(list(map(int, input().split())), reverse=True) -a = A[0] +A = list(map(int, input().split())) +a = max(A) -    ans = 0 -elif K % 2 == 1: -    ans = (a - (K + 1) // 2) * 2 +    print((0)) -    ans = (a - (K + 1) // 2) * 2 - 1 -print(ans) +    print((2 * a - K - 1))