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 MAXL(3 * 1e5);
const int INF(0x3f3f3f3f);
const int mod(1e9 + 7);
int a[2][MAXL + 50];
long long int dp[MAXL + 50];
long long int dp1[MAXL + 50];
long long int dp2[MAXL + 50];
long long int sum[MAXL + 50];
int n;
void init() {
  dp[0] = 0, dp1[n + 1] = dp2[n + 1] = 0, sum[n + 1] = 0;
  for (long long int i = 1, num = 0; i <= n; i++, num += 2) {
    if (i & 1)
      dp[i] = dp[i - 1] + (num * a[0][i] + (num + 1) * a[1][i]);
    else
      dp[i] = dp[i - 1] + (num * a[1][i] + (num + 1) * a[0][i]);
  }
  for (long long int i = n; i >= 1; i--) {
    long long int temp = (i - 1) * 2;
    long long int num = (n - i) * 2;
    sum[i] = sum[i + 1] + a[0][i] + a[1][i];
    dp1[i] =
        dp1[i + 1] - sum[i + 1] + temp * a[0][i] + (temp + num + 1) * a[1][i];
    dp2[i] =
        dp2[i + 1] - sum[i + 1] + temp * a[1][i] + (temp + num + 1) * a[0][i];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[0][i]);
  for (int i = 1; i <= n; i++) scanf("%d", &a[1][i]);
  init();
  long long int ans = 0;
  for (int i = 0; i <= n; i++) {
    if (i & 1)
      ans = max(ans, dp[i] + dp2[i + 1]);
    else
      ans = max(ans, dp[i] + dp1[i + 1]);
  }
  cout << ans << endl;
}
