#include <bits/stdc++.h>

using namespace std;

#define closeSync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
const int MAXN = 10005;

ll p[MAXN];
int n;
ll a[MAXN],b[MAXN],pre[MAXN],suf[MAXN];

inline void solve()
{
    cin >> n;
    for (int i=1;i<=n;i++)
        cin >> a[i];     
    for (int i=1;i<=n;i++)
    {
        cin >> b[i];
        pre[i] = pre[i-1] + a[i] * b[i];
    }   
    for (int i=n;i>=1;i--)
        suf[i] = suf[i+1] + a[i] * b[i];
    ll ans = pre[n];
    //cout << ans << endl;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=i;j++)
        {
            if (i != j)
                p[i+j] += a[i] * b[j] + a[j] * b[i];
            else 
                p[i+j] += a[i] * b[j];
        }   
        for (int j=i+1;j<=i+i;j++)
        {
            ans = max(ans,pre[j-i-1]+p[j]+suf[i+1]);
        }
    }
    cout << ans << "\n";

    return ;
}

int main()
{closeSync;
    // int T;  cin >> T;
    // while (T--)
        solve();
    return 0;
}