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;
int n;
int a[300005][2];
long long dp1[300005][2];
long long dp[300005][2];
long long sum[300005];
int main() {
  scanf("%d", &n);
  for (int j = 0; j < 2; j++)
    for (int i = 0; i < n; i++) scanf("%d", &a[i][j]);
  dp1[n - 1][0] = a[n - 1][1];
  dp1[n - 1][1] = a[n - 1][0];
  sum[n - 1] = a[n - 1][0] + a[n - 1][1];
  for (int i = n - 2; i >= 0; i--) {
    sum[i] = sum[i + 1] + a[i][0] + a[i][1];
    for (int j = 0; j < 2; j++) {
      dp1[i][j] =
          dp1[i + 1][j] + sum[i + 1] + (2ll * (n - i - 1) + 1) * a[i][j ^ 1];
    }
  }
  dp[n - 1][0] = a[n - 1][1];
  dp[n - 1][1] = a[n - 1][0];
  for (int i = n - 2; i >= 0; i--) {
    for (int j = 0; j < 2; j++) {
      long long ans1 = dp1[i][j];
      long long ans2 = a[i][j ^ 1] + sum[i + 1] * 2 + dp[i + 1][j ^ 1];
      dp[i][j] = max(ans1, ans2);
    }
  }
  printf("%I64d\n", dp[0][0]);
  return 0;
}
