#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <deque>

using namespace std;

#define int long long

signed main()
{
    int n, l, r, mx = 0, cnt, sum, mn;
    cin >> n;
    vector<int>a(n);
    vector<int>b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];

    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    for (l = 0; l<n; l++)
    {
        for (r = l; r < n; r++)
        {
            sum = 0;
            mn = 1e9+1;
            for (int i = l; i <= r; i++)
            {
                sum += a[i];
                if (b[i] < mn)
                {
                    mn = b[i];
                }
            }
            cnt = mn * sum;
            if (mx <= cnt)
            {
                mx = cnt;
            }
        }
    }
    cout << mx; 
}