#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define F first
#define S second
#define pb push_back
#define lg2(x) 31-__builtin_clz(x)
#define lg(x,b) log(b)/log(x)

int n,ar[5001],br[5001],s[5001],k,ans;

int sum(int x, int y){
    return s[x-1]+s[n]-s[y];
}

int32_t main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);

cin>>n;
for(int i=1;i<=n;i++)cin>>ar[i];
for(int i=1;i<=n;i++){
    cin>>br[i];
    s[i]=s[i-1]+ar[i]*br[i];
}

ans=s[n];
for(int i=2;i<n;i++){
    k=ar[i]*br[i];
    for(int j=1;j<i && j<=n-i;j++){
        k+=ar[i-j]*br[i+j]+ar[i+j]*br[i-j];
        ans=max(ans,sum(i-j,i+j)+k);
    }
}
for(int i=1;i<n;i++){
    k=ar[i]*br[i+1]+ar[i+1]*br[i];
    ans=max(ans,sum(i,i+1)+k);
    for(int j=1;j<i && j<n-i;j++){
        k+=ar[i-j]*br[i+j+1]+ar[i+j+1]*br[i-j];
        ans=max(ans,sum(i-j,i+j+1)+k);
    }
}

cout<<ans;

return 0;
}
