main = do n <- readLn :: IO Int vs <- (map read . words) <$> getLine putStrLn . show $ resolve vs resolve vs = resolve' vs 0 0 0 where resolve' [] a b c = max b c resolve' (n:ns) a b c = resolve' ns b c (max (a+n) (b+n))