loop do
    n = gets.to_i
    break if n == 0
    pipes = gets.split.map(&:to_i)
    joints = gets.split.map(&:to_i)
    h = {1 => pipes.shift}
    (0..n-2).each do |i|
        new_h = Hash.new(0)
        h.each_key do |k|
            x = h[k] + pipes[i]
            new_h[k+1] = x if x > new_h[k+1]
            x += joints[i]
            new_h[k] = x if x > new_h[k]
        end
        h = new_h
    end
    p h.map {|k, l| k * l}.max
end
