import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    while(true) {
        int n = readln.chomp.to!int;
        if (n==0) break;
        long[] p = readln.split.to!(long[]);
        long[] j = readln.split.to!(long[]);

        int[] ary = (n-1).iota.array;
        sort!((a,b)=>a[1]>b[1])(zip(ary, j.dup));
        long num = n*p.sum;
        foreach(i; 0..ary.length) {
            long[] _p = p[0..ary[i]] ~ (p[ary[i]]+j[ary[i]]+p[ary[i]+1]) ~ (ary[i]+2<p.length ? p[ary[i]+2..$]:[]);
            long[] _j = j[0..ary[i]] ~ j[ary[i]+1..$];
            long _num = _p.length*_p.sum;
            if (_num > num) {
                p = _p;
                j = _j;
                num = _num;
                ary = ary.map!(a=>a>ary[i]?a-1:a).array;
            } else {
                break;
            }
        }
        num.writeln;
    }
}