6
12 8 12 17 20 5
17 4 8 8 8 4
 6
4 1 12 9 3 11
12 20 19 12 19 11
 1
1
1
 2
1 2
1 1
 1
7
5
 6
16 20 18 7 14 2
17 12 4 10 7 4

705
 917
 1
 9
 5
 741

#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;
}
