#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
const int N = 5e3+5;
int n;
ll a[N],b[N],dp[N][N],sum;
ll swag(int x,int y){
    return -a[x]*b[x]-a[y]*b[y]+a[x]*b[y]+a[y]*b[x];
}
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i],sum+=a[i]*b[i];
    for(int l=1;l<=n;l++){
        for(int i=1;i+l<=n;i++){
            if(i+1>=i+l-1) dp[i][i+l]= swag(i,i+l);
            else dp[i][i+l]=dp[i+1][i+l-1]+swag(i,i+l);//
        }
    }
    ll ans = sum;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            ans = max(ans,sum+dp[i][j]);
        }
    }
    cout<<ans<<endl;
}