#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<long long> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    unsigned long long pr = 0;
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
        pr += a[i] * b[i];
    }

    vector<vector<unsigned long long>> f(n, vector<unsigned long long>(n, 0));
    for (int i = 0; i < n - 1; ++i) {
        f[i][i] = pr;
        f[i + 1][i] = pr;
    }
    f[n - 1][n - 1] = pr;
    
    for (int d = 1; d < n; ++d) {
        for (int i = 0; i < n - d; ++i) {
            int j = i + d;
            f[i][j] = f[i + 1][j - 1] + a[j] * b[i] + a[i] * b[j] - a[i] * b[i] - a[j] * b[j];
        }
    }

    unsigned long long ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i; j < n; ++j) {
            ans = max(ans, f[i][j]);
        }
    }

    cout << ans << endl;

    return 0;
}