#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll a[5005],b[5005],l[5005],r[5005];

ll multrev(int le, int ri) {
    ll ret = 0;
    for(int i=0; i<=ri-le; i++)
        ret += b[le+i]*a[ri-i];
    return ret;
}

int main() {
    ll t, n,m,k;
    ll res = 0;
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>a[i];
    for(int i=1; i<=n; i++)
        cin>>b[i];
    for(int i=1; i<=n; i++)
        l[i] = l[i-1] + a[i]*b[i];
    for(int i=n; i>=1; i--)
        r[i] = r[i+1] + a[i]*b[i];
    
    res = l[n];

    for(int c=1; c<n; c++) {
        ll mid = 0;
        for(int d=0; d<=n; d++) {//for even length
            int le = c-d;
            int ri = c+1+d;
            if(le<1 || ri>n)
                break;
            mid += a[le]*b[ri]+a[ri]*b[le];
            res = max(res, mid+l[le-1]+r[ri+1]);
            // cout<<le<<" "<<ri<<"\n";
        }
        mid = a[c]*b[c];
        for(int d=1; d<=n; d++) {//for odd length
            int le = c-d;
            int ri = c+d;
            if(le<1 || ri>n)
                break;
            mid += a[le]*b[ri]+a[ri]*b[le];
            res = max(res, mid+l[le-1]+r[ri+1]);
            // cout<<le<<" "<<ri<<"\n"; 
        }
    }
    cout<<res;
    
    return 0;
}