#include <bits/stdc++.h>
const long long N = 500005;
const long long mod = 1e9 + 7;
using namespace std;
long long a[N][2];
long long dp[N][3][2];
void solve() {
  long long n, m, k = 0, x = 0, y = 0, c = 0, q, ans = 0;
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i][0];
    dp[i][1][0] = (i > 0 ? dp[i - 1][1][0] : 0) + (i)*a[i][0];
    dp[i][0][0] = (i > 0 ? dp[i - 1][0][0] : 0) + a[i][0];
  }
  for (long long i = 0; i < n; ++i) {
    cin >> a[i][1];
    dp[i][2][0] += (i > 0 ? dp[i - 1][2][0] : 0) + (i)*a[i][1];
  }
  for (long long i = n - 1; i >= 0; --i) {
    dp[i][2][1] = (i == n - 1 ? dp[i][2][0] : dp[i + 1][2][1]) +
                  (2 * n - 1 - i) * a[i][0];
  }
  for (long long i = n - 1; i >= 0; --i) {
    dp[i][1][1] = (i == n - 1 ? dp[i][1][0] : dp[i + 1][1][1]) +
                  (2 * n - 1 - i) * a[i][1];
    dp[i][0][1] = (i == n - 1 ? dp[i][0][0] : dp[i + 1][0][1]) + a[i][1];
  }
  ans = dp[0][1][1];
  for (long long i = 0; i < n; ++i) {
    c += 2 * i * a[i][k] + (2 * i + 1) * a[i][k ^ 1];
    if (i % 2 == 0)
      ans = max(ans, c + (dp[i + 1][2][1] - dp[i][2][0]) +
                         (i + 1) * (dp[i + 1][0][1] - dp[i][0][0]));
    else
      ans = max(ans, c + (dp[i + 1][1][1] - dp[i][1][0]) +
                         (i + 1) * (dp[i + 1][0][1] - dp[i][0][0]));
    k ^= 1;
  }
  cout << ans << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
