module Main where main :: IO () main = interact solution windows :: Int -> [a] -> [[a]] windows _ [] = [] windows n (a:r) = take n (a:r) : windows n r solution :: String -> String solution = show . sum . map (fromEnum . (\(a:b:_) -> a < b) ) . init . windows 2 . map sum . init . init . windows 3 . map (read :: String -> Int) . lines