program prob5
    implicit none
    integer(8)::K,T,i,j,s,ans
    integer,allocatable::a(:)
    read(*,*) K,T
    allocate(a(T))
    read(*,*) a
    s = sum(a)
    ans = 0
    do i = 1, T
        if(a(i) >= (s+1)/2) then
            ans = a(i) - (s-a(i)) -1
        end if
    end do

    write(*,*) ans
 
    stop
end program