#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 300000;
int n;
int g[2][MAXN];
long long suffsum[2][MAXN + 1];
long long wsuffsum[2][MAXN + 1];
long long dp[2][MAXN + 1];
void run() {
  scanf("%d", &n);
  for (int x = (0); x < (2); ++x)
    for (int y = (0); y < (n); ++y) scanf("%d", &g[x][y]);
  for (int x = (0); x < (2); ++x) {
    suffsum[x][n] = 0;
    for (int y = n - 1; y >= 0; --y)
      suffsum[x][y] = suffsum[x][y + 1] + g[x][y];
  }
  for (int x = (0); x < (2); ++x) {
    wsuffsum[x][n] = 0;
    for (int y = n - 1; y >= 0; --y)
      wsuffsum[x][y] = wsuffsum[x][y + 1] + (long long)y * g[x][y];
  }
  dp[0][n] = dp[1][n] = 0;
  for (int y = n - 1; y >= 0; --y)
    for (int x = (0); x < (2); ++x) {
      long long a = 0 * g[x][y] + 1 * g[1 - x][y] +
                    2 * (suffsum[0][y + 1] + suffsum[1][y + 1]) +
                    dp[1 - x][y + 1];
      long long b = wsuffsum[x][y] - y * suffsum[x][y] +
                    (n - y) * suffsum[1 - x][y] + (n - 1) * suffsum[1 - x][y] -
                    wsuffsum[1 - x][y];
      dp[x][y] = max(a, b);
    }
  printf("%lld\n", dp[0][0]);
}
int main() {
  run();
  return 0;
}
