#include <bits/stdc++.h>
using namespace std;
int n;
long long x, su[2][300200], ss[2][300200], ni[2][300200], nn[2][300200],
    sum[2][300200];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &sum[0][i]);
  for (int i = 1; i <= n; i++) scanf("%lld", &sum[1][i]);
  su[0][0] = ss[0][0] = x = 0;
  for (int i = 1; i <= n; i++) {
    su[0][i] = sum[0][i] * x + su[0][i - 1];
    ss[0][i] = sum[0][i] + ss[0][i - 1];
    x++;
  }
  su[1][n + 1] = su[0][n];
  ss[1][n + 1] = ss[0][n];
  for (int i = n; i > 0; i--) {
    su[1][i] = sum[1][i] * x + su[1][i + 1];
    ss[1][i] = sum[1][i] + ss[1][i + 1];
    x++;
  }
  ni[1][0] = nn[1][0] = x = 0;
  for (int i = 1; i <= n; i++) {
    ni[1][i] = sum[1][i] * x + ni[1][i - 1];
    nn[1][i] = sum[1][i] + nn[1][i - 1];
    x++;
  }
  ni[0][n + 1] = ni[1][n];
  nn[0][n + 1] = nn[1][n];
  for (int i = n; i > 0; i--) {
    ni[0][i] = sum[0][i] * x + ni[0][i + 1];
    nn[0][i] = sum[0][i] + nn[0][i + 1];
    x++;
  }
  x = 0;
  sum[0][0] = 0;
  for (int i = 1; i <= n; i += 2) {
    sum[0][i] = sum[0][i - 1] + sum[0][i] * x;
    x++;
    sum[1][i] = sum[0][i] + sum[1][i] * x;
    x++;
    if (i + 1 > n) break;
    sum[1][i + 1] = sum[1][i] + sum[1][i + 1] * x;
    x++;
    sum[0][i + 1] = sum[1][i + 1] + sum[0][i + 1] * x;
    x++;
  }
  long long dd = n % 2 == 1 ? sum[1][n] : sum[0][n];
  x = 0;
  for (int i = 1; i <= n; i += 2) {
    dd = max(dd, sum[0][i - 1] + (su[1][i] - su[0][i - 1]) +
                     (ss[1][i] - ss[0][i - 1]) * (i - 1));
    if (i + 1 > n) break;
    dd = max(dd, sum[1][i] + (ni[0][i + 1] - ni[1][i]) +
                     (nn[0][i + 1] - nn[1][i]) * (i));
    x++;
  }
  printf("%lld\n", dd);
  return 0;
}
