#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
long long a[maxn], b[maxn];
long long sum[3][maxn], 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]);
    cs[n] = a[n] + b[n];
    for (long long i = n - 1; i >= 1; i--) {
      cs[i] = cs[i + 1] + a[i] + b[i];
    }
    sum[1][n] = b[n];
    sum[2][n] = a[n];
    for (long long i = n - 1; i >= 1; i--) {
      sum[1][i] = sum[1][i + 1] + cs[i + 1] + (2 * (n - i + 1) - 1) * b[i];
      sum[2][i] = sum[2][i + 1] + cs[i + 1] + (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;
}
