import Control.Applicative
import Control.Monad
import Data.List

main = do
    [k, t] <- fmap read . words <$> getLine :: IO [Int]
    as <- sortBy (flip compare) . fmap read . words <$> getLine :: IO [Int]
    case as of
        (b:[]) -> print $ b - 1
        (b:bs) | b <= sum bs -> print 0
               | otherwise   -> print $ b - sum bs - 1