import Control.Applicative

import Control.Monad
    (replicateM, when)
    
type Set = [Int]

type Problem = (Int, Set)

type Result = Int

sub :: Int -> Int -> [Int] -> [Int]

sub i n list
    = take n $ drop i list
    
solve :: Problem -> Result

solve (n, set)
    = subs where
        subs = foldl1 max [foldl1 max [sum $ sub x y set | y <- [1..(n - x)]] | x <- [0..(n - 1)]]
    
main :: IO ()

main
    = do
        n <- readLn
        when (n /= 0) $ do
            set <- replicateM n readLn
            print $ solve (n, set)
            main