#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> a(2, vector<int>(n));
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> a[i][j];
    }
  }
  vector<vector<long long>> pref(2, vector<long long>(n + 1));
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < n; ++j) {
      pref[i][j + 1] = pref[i][j] + a[i][j];
    }
  }
  vector<vector<long long>> go(2, vector<long long>(2 * n + 1));
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < n; ++j) {
      go[i][j + 1] = go[i][j] + (long long)j * a[i][j];
    }
  }
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < n; ++j) {
      go[i][j + n + 1] =
          go[i][j + n] + (long long)(j + n) * a[i ^ 1][n - 1 - j];
    }
  }
  function<long long(int, int)> solve = [&](int i, int j) -> long long {
    if (j == n) return 0LL;
    int done = j * 2;
    int left = 2 * n - done;
    long long ret = go[i][j + left] - go[i][j];
    ret += (long long)(done - j) * (pref[0][n] - pref[0][j]);
    ret += (long long)(done - j) * (pref[1][n] - pref[1][j]);
    ret =
        max(ret, (long long)done * a[i][j] +
                     (long long)(done + 1) * a[i ^ 1][j] + solve(i ^ 1, j + 1));
    return ret;
  };
  long long ans = solve(0, 0);
  cout << ans << '\n';
  return 0;
}
