import           Data.List

main :: IO ()
main = do
    [k, t] <- readInts
    as     <- readInts
    print $ solve k t as

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve :: Int -> Int -> [Int] -> Int
solve k t as | x - sum xs <= 1 = 0
             | otherwise       = x - sum xs - 1
    where (x : xs) = sortBy (flip compare) as