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 n, m, q;
long long f[2][300005], a[2][300005], s[2][300005], p, px, py;
int main() {
  scanf("%d", &n);
  for (int i = 0; i <= 1; i++)
    for (int j = 0; j < n; j++) cin >> a[i][j];
  for (int i = 0; i <= 1; i++)
    for (int j = n - 1; j >= 0; j--) {
      px = i ^ 1;
      if (j % 2 != i) {
        s[i][j] = s[i][j + 1] + a[i][j];
        f[i][j] = f[i][j + 1] + a[i][j] * (j * 2 + 1);
      } else {
        s[i][j] = s[i][j + 1] + a[i][j] + a[px][j] + a[px][j + 1];
        f[i][j] = f[i][j + 1] - s[i][j + 1] * 2 + a[i][j] * (j * 2) +
                  a[px][j] * (n * 2 - 1) + a[px][j + 1] * (n * 2 - 2);
      }
    }
  px = 0;
  py = 0;
  p = 0;
  long long ans = 0;
  long long maxans = f[0][0];
  for (int i = 1; i < n * 2; i++) {
    p++;
    if (py % 2 == px)
      px ^= 1;
    else
      py++;
    maxans = max(maxans, ans + (long long)f[px][py]);
    ans += a[px][py] * p;
  }
  cout << maxans << endl;
}
