import Control.Monad
import Control.Applicative
import Data.List

main = do
    n <- readLn
    when (n /= 0) $ do
        xs <- input n read
        print $ solve xs
        main

solve :: [Int] -> Int
solve = maximum . scanl1 accumMax
    where
    accumMax a b = max (a+b) b

input :: Int -> (String -> a) -> IO [a]
input n f = map f <$> replicateM n getLine