import Control.Monad

main :: IO ()
main = do
  n <- readLn

  when (n /= 0) $ do
    as <- replicateM n readLn
    let ss = 0 : scanl1 (+) as
    print $ maximum [ss!!j-ss!!i | i <- [0..n], j <- [i+1..n]]
    main