#include <bits/stdc++.h>
using namespace std;
const int N = 300 * 1000 + 9;
int n;
int a[2][N];
long long sum123[2][N];
long long sum321[2][N];
long long sum111[2][N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < n; ++j) scanf("%d", &a[i][j]);
  for (int i = 0; i < 2; ++i)
    for (int j = n - 1; j >= 0; --j) {
      sum123[i][j] = sum123[i][j + 1] + (j + 1) * 1LL * a[i][j];
      sum321[i][j] = sum321[i][j + 1] + (n - j) * 1LL * a[i][j];
      sum111[i][j] = sum111[i][j + 1] + a[i][j];
    }
  long long res = 0, sum = 0;
  for (int i = 0, j = 0; j < n; ++j, i ^= 1) {
    long long nres = sum;
    nres += sum123[i][j] + j * 1LL * sum111[i][j];
    nres += sum321[i ^ 1][j] + (j + n) * 1LL * sum111[i ^ 1][j];
    res = max(res, nres);
    sum += a[i][j] * 1ll * (j + j + 1);
    sum += a[i ^ 1][j] * 1ll * (j + j + 2);
  }
  for (int j = 0; j < n; ++j) res -= a[0][j] + a[1][j];
  printf("%I64d\n", res);
  return 0;
}
