while n=gets.to_i
  exit if n==0
  pipelen = gets.split(nil).inject(0){|sum, e|sum+e.to_i}
  joint = gets.split(nil).map(&:to_i).sort.reverse
  until joint.empty?
    break if pipelen*n > (pipelen+joint[0])*(n-1)
    n-=1
    pipelen+=joint.shift
  end
  puts pipelen*n
end