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 maxn = 300000 + 100, INF = 1 << 30;
int N, A[maxn], B[maxn], ap[maxn], bp[maxn];
long long tmp, ans = 0ll, suf[maxn], sum[maxn << 1], f[2][maxn];
void Init() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
  for (int i = 1; i <= N; ++i) scanf("%d", &B[i]);
}
void Solve() {
  int cnt = 1;
  ap[1] = 1;
  for (int i = 2; i <= (N << 1); ++i) {
    if (cnt == 1) tmp = 1ll * B[i >> 1] * (i - 1), bp[i >> 1] = i;
    if (cnt == 2) tmp = 1ll * B[(i >> 1) + 1] * (i - 1), bp[(i >> 1) + 1] = i;
    if (cnt == 3) tmp = 1ll * A[i >> 1] * (i - 1), ap[i >> 1] = i;
    if (cnt == 4) tmp = 1ll * A[(i >> 1) + 1] * (i - 1), ap[(i >> 1) + 1] = i;
    sum[i] = sum[i - 1] + tmp, cnt++;
    if (cnt == 5) cnt = 1;
  }
  for (int i = N; i >= 1; --i) suf[i] = suf[i + 1] + A[i] + B[i];
  f[0][N] = 1ll * A[N] * ((N << 1) - 2) + 1ll * B[N] * ((N << 1) - 1);
  for (int i = N - 1; i >= 1; --i) {
    f[0][i] = f[0][i + 2] - 2ll * suf[i + 2];
    f[0][i] += 1ll * A[i] * (i - 1) * 2 + 1ll * A[i + 1] * ((i - 1) * 2 + 1);
    f[0][i] += 1ll * B[i] * ((N << 1) - 1) + 1ll * B[i + 1] * ((N << 1) - 2);
  }
  f[1][N] = 1ll * A[N] * ((N << 1) - 1) + 1ll * B[N] * ((N << 1) - 2);
  for (int i = N - 1; i >= 1; --i) {
    f[1][i] = f[1][i + 2] - 2ll * suf[i + 2];
    f[1][i] += 1ll * B[i] * (i - 1) * 2 + 1ll * B[i + 1] * ((i - 1) * 2 + 1);
    f[1][i] += 1ll * A[i] * ((N << 1) - 1) + 1ll * A[i + 1] * ((N << 1) - 2);
  }
  ans = f[0][1];
  for (int i = 1; i <= N; ++i)
    if (!(i & 1)) ans = max(ans, sum[ap[i]] + f[0][i + 1]);
  for (int i = 1; i <= N; ++i)
    if (i & 1) ans = max(ans, sum[bp[i]] + f[1][i + 1]);
  printf("%I64d\n", ans);
}
int main() {
  Init(), Solve();
  return 0;
}
