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;
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;
}
