    #include<cstdio>
    #include<iostream>
    #define ll long long
    using namespace std;
    ll sum1[5005];
    ll sum2[5005][5005];
    ll a[5005];
    ll b[5005];
    int main(){
    	int n;
    	scanf("%d",&n);
    	for(int i=1;i<=n;i++){
    		scanf("%lld",&a[i]);
    	}
    	for(int i=1;i<=n;i++){
    		scanf("%lld",&b[i]);
    	}
    	for(int i=1;i<=n;i++){
    		sum1[i]=sum1[i-1]+a[i]*b[i];
    	}
    	for(int i=1;i<=n;i++){
    		for(int j=0;i-j>=1&&i+j<=n;j++){
    			if(j==0) sum2[i][i]=a[i]*b[i];
    			else sum2[i-j][i+j]=sum2[i-j+1][i+j-1]+a[i-j]*b[i+j]+a[i+j]*b[i-j];
    		}
    	}
    	for(int i=1;i<n;i++){
    		for(int j=0;i-j>=1&&i+1+j<=n;j++){
    			if(j==0) sum2[i][i+1]=a[i]*b[i+1]+a[i+1]*b[i];
    			else sum2[i-j][i+1+j]=sum2[i-j+1][i+1+j-1]+a[i-j]*b[i+1+j]+a[i+1+j]*b[i-j];
    		}
    	}
    	ll ans=sum1[n];
    	for(int i=1;i<=n;i++){
    		for(int j=i;j<=n;j++){
    			ans=max(ans,sum1[n]-(sum1[j]-sum1[i-1])+sum2[i][j]);
    		}
    	}
    	printf("%lld",ans);
    	return 0;
    }