main :: IO () main = do _n <- getLine getLine >>= print . solve . map read . words solve :: [Int] -> Int solve v = solve' v ((0, 0), (0, 0), (0, 0)) where solve' :: [Int] -> ((Int, Int), (Int, Int), (Int, Int)) -> Int solve' [] (_, _, (e, f)) = max e f solve' (h:t) ((a, b), (c, d), e) = solve' t ((c, d), e, (h + max c d, h + max a b))