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 = 3e5 + 3;
int n;
long long a[N], b[N];
long long g[N][2], f[N][2], s[N];
long long ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%lld", &b[i]);
  memset(g, 0, sizeof g);
  memset(s, 0, sizeof s);
  memset(f, 0, sizeof f);
  s[n] = a[n] + b[n];
  g[n][0] = a[n] * (2 * n - 2) + b[n] * (2 * n - 1);
  g[n][1] = a[n] * (2 * n - 1);
  for (int i = n - 1; i >= 1; i--)
    s[i] = s[i + 1] + a[i] + b[i],
    g[i][0] = a[i] * 2 * (i - 1) + g[i + 1][0] - s[i + 1] + b[i] * (2 * n - 1),
    g[i][1] = b[i + 1] * (2 * (i - 1) + 1) + g[i + 1][1] - s[i + 2] - a[i + 1] +
              a[i] * (2 * n - 1);
  ans = g[1][0];
  f[1][0] = b[1];
  for (int i = 2; i <= n; i++)
    f[i][1] = f[i - 1][0] + b[i] * (i - 1) * 2,
    ans = max(ans, f[i][1] + g[i][1]), f[i][0] = f[i][1] + a[i] * (i * 2 - 1),
    ans = max(ans, f[i][0] + g[i + 1][0]);
  printf("%lld", ans);
  return 0;
}
