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;
long long dp[300010], tmp[300010][2];
int a[300010], b[300010];
long long sum[300010][2];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (int i = n; i; i--) {
    sum[i][0] = sum[i + 1][0] + a[i];
    sum[i][1] = sum[i + 1][1] + b[i];
  }
  for (int i = n; i; i--) {
    int x = (n - i + 1) * 2 - 1;
    tmp[i][0] =
        tmp[i + 1][0] + sum[i + 1][0] + sum[i + 1][1] + (long long)x * b[i];
    tmp[i][1] =
        tmp[i + 1][1] + sum[i + 1][1] + sum[i + 1][0] + (long long)x * a[i];
  }
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1];
    int x = (i - 1) * 2;
    if (i % 2)
      dp[i] += (long long)x * a[i] + (long long)(x + 1) * b[i];
    else
      dp[i] += (long long)x * b[i] + (long long)(x + 1) * a[i];
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long val = dp[i];
    int x = i * 2;
    if (i % 2)
      val += tmp[i + 1][1] + (long long)x * (sum[i + 1][0] + sum[i + 1][1]);
    else
      val += tmp[i + 1][0] + (long long)x * (sum[i + 1][0] + sum[i + 1][1]);
    ans = max(ans, val);
  }
  ans = max(ans, tmp[1][0]);
  cout << ans << endl;
}
