program sample
    implicit none
  
    integer(8) :: i,j,m,n,k,t
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) k,t
    allocate(x(t))
    read(*,*)x
    m=maxval(x)
    n=sum(x)-m
    if (m-n-1<0)then
        write(*,*)0
    else
    write(*,*) m-n-1
    end if
  
    stop
end program sample
  

