import qualified Data.ByteString.Lazy.Char8 as B
import Data.ByteString.Lazy.Char8 (ByteString)
import Control.Monad.Trans.State.Strict
import Control.Applicative (many)
import Data.Char (isSpace)

main :: IO ()
main = B.interact $ output . solve . input

output :: Int -> ByteString
output = B.pack . show
{-# INLINE output #-}

solve :: [Int] -> Int
solve = sum . map pred
{-# INLINE solve #-}

input :: ByteString -> [Int]
input = maybe (error "parse error") fst . runStateT (parseInt *> many parseInt)
{-# INLINE  input #-}

parseInt :: StateT ByteString Maybe Int
parseInt = StateT $ B.readInt . B.dropWhile isSpace
{-# INLINE paeseInt #-}
