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 = 1e6 + 5;
const int mod = 1e9 + 7;
long long n, m;
long long H, ans, la;
long long a[maxn], S[maxn], sum[maxn], X[maxn], b[maxn];
int f(int x) { return 2 * x; }
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%lld", &b[i]);
  for (int i = n; i > 1; i--) {
    sum[i] = sum[i + 1] + a[i] + b[i];
    X[i] = X[i + 1] + sum[i + 1] + b[i] + (n - i + 1) * 2 * a[i];
    S[i] = S[i + 1] + sum[i + 1] + a[i] + (n - i + 1) * 2 * b[i];
  }
  long long t = 0;
  for (int i = 2; i <= n; i++) {
    ans += (++t) * a[i];
  }
  for (int i = n; i >= 0; i--) {
    ans += (++t) * b[i];
  }
  H = b[1];
  for (int i = 2; i <= n; i++) {
    if (i & 1) {
      ans = max(ans, H + S[i] + (i * 2 - 3) * sum[i]);
      H += f(i) * b[i] + f(i) * a[i];
      H -= b[i] + 2 * a[i];
    } else {
      ans = max(ans, H + X[i] + (i * 2 - 3) * sum[i]);
      H += (i * 2) * b[i] + (i * 2) * a[i];
      H -= a[i] + 2 * b[i];
    }
  }
  printf("%lld", ans);
}
