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>
int Max(int p, int q) {
  if (p < q) return q;
  return p;
}
int n, a[300005], b[300005];
long long int dp[300005][3], sum[300005][3], Sum[300005];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);
  Sum[n - 1] = a[n - 1] + b[n - 1];
  for (int i = n - 2; i >= 0; i--) Sum[i] = Sum[i + 1] + a[i] + b[i];
  sum[n - 1][0] = b[n - 1], sum[n - 1][1] = a[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    sum[i][0] = sum[i + 1][0] + Sum[i + 1] + (2 * (n - i) - 1) * b[i];
    sum[i][1] = sum[i + 1][1] + Sum[i + 1] + (2 * (n - i) - 1) * a[i];
  }
  dp[n - 1][0] = b[n - 1], dp[n - 1][1] = a[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    dp[i][0] = Max(b[i] + dp[i + 1][1] + 2 * Sum[i + 1], sum[i][0]);
    dp[i][1] = Max(a[i] + dp[i + 1][0] + 2 * Sum[i + 1], sum[i][1]);
  }
  printf("%I64d\n", dp[0][0]);
  return 0;
}
