loop do
  n = gets.to_i
  break if n==0
  arr = []
  n.times{ arr << gets.to_i }
  max = 0
  (0...n).each do |i|
    (1..(n-i)).each do |j|
      max = [max, arr[i, j].inject(:+)].max
    end
  end
  puts max
end