import Data.List

split' :: [Int]	-> [[Int]]
split' (x:xs)
  | x == 0 = []
  | otherwise =	take x xs : split' (drop x xs)

solve :: [Int] -> String
solve = show . maximum . map (maximum . scanl1 (+)) . init . tails

main = getContents >>= putStr . unlines . map solve . split' . map read . lines