import Control.Applicative
import Control.Monad

main = do
    n <- readLn
    if n == 0 then return ()
              else do
                  list <- replicateM n (read<$>getLine)
                  print $ maximumSeqSum list
                  main
maximumSeqSum :: [Int] -> Int
maximumSeqSum lst = maximum $ (map maxSeqSum [1..n]) <*> [lst]
    where n = length lst

maxSeqSum :: (Num a, Ord a) => Int -> [a] -> a
maxSeqSum n = maximum.seqSums n
seqSums :: Num a => Int -> [a] -> [a]
seqSums _ []  = []
seqSums n lst = (sum.take n $ lst) : seqSums n (tail lst)