#include <bits/stdc++.h>
using namespace std;
long long int dp1[5001][5001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    long long int a[n];
    long long int b[n];
    long long int age_se[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
        if (i == 0)
        {
            age_se[i] = a[i] * b[i];
        }
        else
        {
            age_se[i] = age_se[i - 1] + a[i] * b[i];
        }
    }
    long long int piche_se[n];
    for (int i = n - 1; i >= 0; i--)
    {
        if (i == (n - 1))
        {
            piche_se[i] = a[i] * b[i];
        }
        else
        {
            piche_se[i] = piche_se[i + 1] + a[i] * b[i];
        }
    }
    for (int k = 1; k <= n; k++)
    {
        for (int i = 0; i < n; i++)
        {
            if ((i + k) >= n)
            {
                break;
            }
            int j = i + k;
            if (k == 1)
            {
                dp1[i][j] = a[i] * b[j] + a[j] * b[i];
            }
            else if (k == 2)
            {
                dp1[i][j] = a[i] * b[i + 2] + a[i + 1] * b[i + 1] + a[i + 2] * b[i];
            }
            else
            {
                dp1[i][j] = dp1[i + 1][j - 1] + a[i] * b[j] + a[j] * b[i];
            }
        }
    }
    long long int maxi = age_se[n - 1];
    for (int i = 0; i < n; i++)
    {

        for (int j = i + 1; j < n; j++)
        {
            long long int sum = dp1[i][j];
            if (i > 0)
            {
                sum = sum + age_se[i - 1];
            }
            if (j != (n - 1))
            {
                sum = sum + piche_se[j + 1];
            }
            if (sum > maxi)
            {
                maxi = sum;
            }
        }
        // cout<<maxi<<endl;
    }
    cout << maxi << endl;
}