import Data.Array
main = do
  n <- getLine
  vs <- map read . words <$> getLine :: IO [Int]
  putStrLn $ show $ head $ maxTaste vs

maxTaste :: [Int] -> [Int]
maxTaste [v] = [v]
maxTaste (v:[v']) = max v v':[v']
maxTaste (v:v':v'':vs) =
  let
    ts'@(t':t'':ts) = maxTaste (v':v'':vs)
  in
    max (v + t'') t':ts'