#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
signed main()
{
    ios_base::sync_with_stdio( false );
    cin.tie( nullptr ), cout.tie( nullptr );
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (auto &x : a) cin >> x;
    for (auto &x : b) cin >> x;
    vector < ll > pr( n + 1, 0 );
    for (int i = 0; i < n; ++i)
        pr[i + 1] = pr[i] + a[i] * b[i];
    ll sum = pr[n ];
    for (int i = 0 ; i < n ; ++i) {
        ll flag =  a[i] * b[i];
        for (int l = i - 1, r = i + 1 ; l >= 0 && r < n ; --l, ++r) {
            flag +=  a[l] * b[r] ;
            flag+=a[r] * b[l];
            sum = max( sum, flag + pr[l ] + pr[n ] - pr[r+1] );
        }
        flag = 0;
        for (int l = i, r = i + 1 ; l >= 0 && r < n ; --l, ++r) {
            flag +=  a[l] * b[r] ;
            flag+=a[r] * b[l];
            sum = max( sum, flag + pr[l ] + pr[n ] - pr[r+1] );
        }
    }
    cout << sum << endl;
}