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 = 3e5 + 10;
long long a[maxn], b[maxn];
long long sum[2][maxn];
long long cs[maxn];
int main() {
  long long n;
  while (scanf("%lld", &n) != EOF) {
    memset(sum, 0, sizeof(sum));
    memset(cs, 0, sizeof(cs));
    for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
    for (long long i = 1; i <= n; i++) scanf("%lld", &b[i]);
    for (long long i = n; i >= 1; i--) {
      cs[i] = cs[i + 1] + a[i] + b[i];
    }
    for (long long i = n; i >= 1; i--) {
      sum[1][i] = sum[1][i + 1] + cs[i + 1];
      sum[1][i] += (2 * (n - i + 1) - 1) * b[i];
      sum[2][i] = sum[2][i + 1] + cs[i + 1];
      sum[2][i] += (2 * (n - i + 1) - 1) * a[i];
    }
    long long ans = sum[1][1];
    long long ss = 0;
    for (long long i = 1; i <= n; i++) {
      if (i % 2) {
        ss += (i * 2 - 2) * a[i] + (i * 2 - 1) * b[i];
      } else
        ss += (i * 2 - 2) * b[i] + (i * 2 - 1) * a[i];
      ans = max(ans, ss + cs[i + 1] * 2ll * i + sum[i % 2 ? 2 : 1][i + 1]);
    }
    printf("%lld\n", ans);
  }
  return 0;
}
