import Control.Monad import Control.Applicative import Data.List import Data.Array main = do n <- readLn vs <- (map read .words) <$> getLine print (solve n vs) maxs x y = if x >= y then x else y solve n vs | n == 1 = vs !! 0 | n == 2 = maxs (vs !! 0) (vs !! 1) | otherwise = a!n where a = array (1,n) ( (1,(vs !! 0)) : (2,maxs (vs !! 0) (vs !! 1)) : [(i,maxs (a!(i-1)) ((vs !! (i-1)) + a!(i-2)) ) | i <- [3,4..n]] )