#include <bits/stdc++.h>
using namespace std;
typedef  long long   ll;
typedef  long double ld;
typedef __int128 lx;
#define ceil(n, m) ((n / m) + ( n % m ? 1 : 0))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("dream.in", "r", stdin);
    int n;
    cin >> n;
    vector< ll > a(n + 1), b(n + 1);
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
    for(int i = 1; i <= n; ++i)
        cin >> b[i];
    vector< vector< ll > > dp(n + 2, vector< ll > (n + 2));
    for(int i = 1; i <= n; ++i)
        dp[i][i] = a[i] * b[i];
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j < i; ++j)
            if(i != j)
                dp[i][j] = max(dp[i][j], dp[i - 1][j + 1] + (a[i] * b[j]) + (a[j] * b[i]));
    vector< ll > pref(n + 1), suf(n + 2);
    for(int i = 1; i <= n; ++i)
        pref[i] = pref[i - 1] + (a[i] * b[i]);
    for(int i = n; i >= 1; --i)
        suf[i] = suf[i + 1] + (a[i] * b[i]);
    ll ans = pref.back();
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j < i; ++j)
            if(i != j)
                ans = max(ans, pref[j - 1] + suf[i + 1] + dp[i][j]);
    cout << ans;



}