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;
const int maxn = 3e5 + 5;
int n, A[2][maxn];
long long presum[2][maxn], fwd[2][maxn], backward[2][maxn];
long long getsum(int l, int r, int j) {
  if (l == 0)
    return presum[j][r];
  else
    return presum[j][r] - presum[j][l - 1];
}
long long calc(int j, int i) { return fwd[j][i] + backward[j ^ 1][i]; }
int dp[2][maxn];
long long f(int j, int i) {
  if (dp[j][i] >= 0) return dp[j][i];
  long long x = 2 * i;
  if (i == n - 1)
    return dp[j][i] = 1LL * x * A[j][i] + 1LL * (x + 1) * A[j ^ 1][i];
  return dp[j][i] =
             max(calc(j, i), 1LL * x * A[j][i] + 1LL * (x + 1) * A[j ^ 1][i] +
                                 f(j ^ 1, i + 1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      cin >> A[i][j];
      presum[i][j] = A[i][j];
      if (j != 0) presum[i][j] += presum[i][j - 1];
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < 2; j++) {
      if (j == 0) {
        if (i == n - 1) {
          fwd[j][i] = 1LL * (n - 1) * A[j][i];
        } else {
          fwd[j][i] = fwd[j][i + 1] + i * A[j][i];
        }
      } else {
        if (i == n - 1) {
          fwd[j][i] = 1LL * n * A[j][i];
        } else {
          fwd[j][i] = fwd[j][i + 1] + (n + (n - i) - 1) * A[j][i];
        }
      }
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < 2; j++) {
      if (i == n - 1) backward[j][i] = getsum(n - 1, n - 1, j);
      backward[j][i] = backward[j][i + 1] +
                       (2 * (n - i) - 1) * getsum(i, i, j) +
                       getsum(i + 1, n - 1, j);
    }
  }
  memset(dp, -1, sizeof(dp));
  long long ans = f(0, 0);
  cout << ans << '\n';
  return 0;
}
