#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ex 1000000007
ll total;
ll dp[5001][5001];
ll solve(vector<ll> &A,vector<ll> &B,int i,int j){
    if(i>=j)return total;
    if(dp[i][j]!=-1)return dp[i][j];
    // ll left=0,right=0;
    // if(i>0)left=sum1[i-1];
    // right=sum1[A.size()-1]-sum1[j];
    ll ans;
    ans=solve(A,B,i+1,j-1)+A[i]*B[j]+B[i]*A[j]-A[i]*B[i]-A[j]*B[j];
    dp[i][j]=ans;
    return ans;
    
}


int main()
{ll tt=1;
// cin>>tt;
while(tt--){
    ll n;
    cin>>n;
    vector<ll> A(n),B(n);
    for(auto &i:A)cin>>i;
    for(auto &i:B)cin>>i;
    ll ans=0;
    for(int i=0;i<n;i++)ans+=A[i]*B[i];
    
    // memset(sum1,0,sizeof(sum1));
    memset(dp,-1,sizeof(dp));
    // sum1[0]=A[0]*B[0];
    // for(int i=1;i<n;i++)
    // sum1[i]=sum1[i-1]+A[i]*B[i];
    total=ans;
    for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++){
        ans=max(ans,solve(A,B,i,j));
    }
    cout<<ans<<endl;
    
}


  return 0;
}