def solve(as, n, aSum)
  return aSum if n == 1
  l = as.first(as.length - 1)
  lSum = l.inject(:+)
  r = as.last(as.length - 1)
  rSum = r.inject(:+)
  bs, bSum = if lSum < rSum then [r, rSum] else [l, lSum] end
  if aSum < bSum
    solve(bs, n - 1, bSum)
  else
    solve(bs, n - 1, aSum)
  end
end

while true
  n = gets.to_i
  break if n == 0

  as = n.times.map { |i| gets.to_i }
  puts solve(as, n, as.inject(:+))
end