#include<bits/stdc++.h>
#define int long long
#define ld long double
#define fi first
#define se second
#define vll vector<int>
#define pii pair<int,int>
#define pb push_back
#define sz(v) (int)(v).size()
#define inf (int)(1e18)
#define md (int)(1e9+7)
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(int i=a;i<b;++i)
using namespace std;

const int M = 5e3 + 10;

int n,a[M],b[M];
int dp1[M][M];

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
   	
   	cin>>n;
   	rep(i,0,n) cin>>a[i];
   	rep(i,0,n) cin>>b[i];
   	int ans=0;
   	rep(i,0,n) ans+=a[i]*b[i];
   	for(int i=n-1;i>=0;--i) {
   		rep(j,i,n) {
   			dp1[i][j]=b[i]*a[j];
   			if(i!=j) dp1[i][j]+=a[i]*b[j];
   			if(i+1<n and j-1>=i) dp1[i][j]+=dp1[i+1][j-1];
   		}
   	}
   	int mx=ans;
   	rep(i,0,n) {
   		int x=a[i]*b[i];
   		rep(j,i+1,n) {
   			x+=a[j]*b[j];
   			int now=ans-x+dp1[i][j];
   			mx=max(mx,now);
   		}
   	}
   	cout<<mx;
   	
   	
    return 0;
}