import Data.Array
import Data.List
import Control.Monad

main = do
    n <- readLn
    unless ( n == 0) $ do
        nums <- replicateM n readLn
        print $ mss nums
        main

mss :: Int -> [Int] -> Int
mss len list = maximum [arr ! r  - arr ! (l-1) | l <- [1..len], r <- [2..len]]
    where arr = listArray (0,len) $ scanl (+) 0 list