main = getContents >>= mapM_ (print . maximum_sum_seq) . reverse . fin [] . map read . init . lines
fin acc ns = if null ns then acc else fin ((take (head ns) (tail ns)):acc) (drop (head ns) (tail ns))
maximum_sum_seq ns = maximum ns' - minimum ns'
 where ns' = scanl (+) 0 ns