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;
const int N = 300010;
int n, a[2][N];
long long pre[2][N], s[2][N], suf[2][N], sum[N], prex[2][N], sufx[2][N],
    ans = -1;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[0][i]);
  for (int i = 1; i <= n; i++) scanf("%d", &a[1][i]);
  int S = n >> 1, tot = 0;
  for (int i = 1; i <= S * 2; i += 2) {
    s[0][i] = (long long)a[0][i] * tot;
    tot++;
    s[1][i] = (long long)a[1][i] * tot;
    tot++;
    s[1][i + 1] = (long long)a[1][i + 1] * tot;
    tot++;
    s[0][i + 1] = (long long)a[0][i + 1] * tot;
    tot++;
  }
  for (int i = 1; i <= n; i++) {
    pre[0][i] = pre[0][i - 1] + a[0][i];
    pre[1][i] = pre[1][i - 1] + a[1][i];
    sum[i] = sum[i - 1] + s[0][i] + s[1][i];
  }
  for (int i = 1; i <= n; i++) {
    prex[0][i] = prex[0][i - 1] + pre[0][i];
    prex[1][i] = prex[1][i - 1] + pre[1][i];
  }
  for (int i = n; i >= 1; i--) {
    suf[0][i] = suf[0][i + 1] + a[0][i];
    suf[1][i] = suf[1][i + 1] + a[1][i];
  }
  for (int i = n; i >= 1; i--) {
    sufx[0][i] = sufx[0][i + 1] + suf[0][i];
    sufx[1][i] = sufx[1][i + 1] + suf[1][i];
  }
  for (int i = 0; i < n; i++) {
    long long tot = sum[i];
    if (i % 2) {
      tot += (n + i - 1) * (pre[0][n] - pre[0][i]) +
             (prex[0][n] - prex[0][i] - (n - i) * pre[0][i]);
      tot += (i * 2 - 1) * suf[1][i + 1] + (sufx[1][i + 1]);
    } else {
      if (i + 1 == n)
        tot += (i * 2) * (sufx[0][i + 1]);
      else
        tot += (i * 2) * suf[0][i + 1] + (sufx[0][i + 1] - suf[0][i + 1]);
      tot += (n + i - 1) * (pre[1][n] - pre[1][i]) +
             (prex[1][n] - pre[1][i] - (n - i) * prex[1][i]);
    }
    ans = max(ans, tot);
  }
  ans = max(ans, sum[n]);
  printf("%lld", ans);
  return 0;
}
