import Control.Monad import Data.Char main :: IO () main = do input <- liftM (filter isDigit) $ readFile "1.in" print $ sum $ map (\(a,b) -> read [a] * fromEnum (a == b)) $ zip input (tail (cycle input)) print $ sum $ map (\(a,b) -> read [a] * fromEnum (a == b)) $ zip input (drop (length input `div` 2) (cycle input))