#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
const int MAX = 2e9;
ll ps[5005];
ll a[5005],b[5005];
ll dp[5005][5005];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for(int i =1 ; i <= n; i++)cin >> a[i];
    for(int i =1 ; i <= n; i++)cin >> b[i];
    for(int i =1 ; i <= n; i++){
        ps[i] += ps[i-1]+(a[i]*b[i]);
    }
    for(int i = 1; i <= n; i++){
        dp[i][i] = a[i]*b[i];
    }
    for(int i = 1; i < n; i++){
        dp[i][i+1] = (a[i]*b[i+1] + a[i+1]*b[i]);
    }
    for(int j = 3; j <= n; j++){// length
        for(int i = 1; i+j-1<=n; i++){
            dp[i][i+j-1] = dp[i+1][i+j-2] + a[i]*b[i+j-1] + a[i+j-1]*b[i];
        }
    } 
    ll ans = ps[n];
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j++){
            ans = max(ans,ps[i -1] + ps[n] - ps[j] + dp[i][j]);
        }
    }
    cout << ans;
}