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>
inline void read(int& x) {
  char c;
  while ((c = getchar()) < '0' || c > '9')
    ;
  x = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
}
using namespace std;
const int maxn = 3e5 + 10;
const int M = 128;
const int inf = 0x7fffffff;
const long long INF = 9E18;
const int mod = 1e9 + 7;
const int eps = 1e-7;
const double pi = 3.1415926535898;
int a[2][maxn];
long long dp[2][maxn], sum[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) read(a[0][i]);
  for (int i = 1; i <= n; i++) read(a[1][i]);
  for (int i = n; i >= 1; i--) {
    dp[0][i] = dp[0][i + 1] + sum[i + 1] + 1LL * a[1][i] * (1 + 2 * (n - i));
    dp[1][i] = dp[1][i + 1] + sum[i + 1] + 1LL * a[0][i] * (1 + 2 * (n - i));
    sum[i] = sum[i + 1] + a[0][i] + a[1][i];
  }
  long long ans = 0, cur = 0;
  for (int i = 1; i <= n; i++) {
    long long tmp = cur + dp[!(i & 1)][i] + 2 * (i - 1) * sum[i];
    ans = max(tmp, ans);
    if (i & 1) {
      cur += a[0][i] * (i - 1) * 2;
      cur += a[1][i] * (i * 2 - 1);
    } else {
      cur += a[1][i] * (i - 1) * 2;
      cur += a[0][i] * (i * 2 - 1);
    }
  }
  cout << ans << endl;
}
