#include <bits/stdc++.h>
using namespace std;
void solve() {}
const long long maxn = 300500;
long long n;
long long a[2][maxn];
long long pref[2][maxn], suf[2][maxn];
long long psa[2][maxn];
long long f(long long i, long long j, long long time) {
  if (j == n + 1) {
    return 0;
  }
  long long val = f(i ^ 1, j + 1, time + 2) + a[i ^ 1][j] * (time + 1) +
                  a[i ^ 1][j + 1] * (time + 2);
  long long val2 = (pref[i][n] - pref[i][j]) +
                   (time - j) * (psa[i][n] - psa[i][j]) + suf[i ^ 1][j] +
                   (time + n - j) * (psa[i ^ 1][n] - psa[i ^ 1][j - 1]);
  if (j == n) val2 = 0;
  if (false) cerr << '\n';
  if (false) cerr << "on " << i << " " << j << " " << time << '\n';
  if (false)
    cerr << ("(pref[i][n] - pref[i][j]) + (time - j) * (psa[i][n] - psa[i][j])")
         << " is "
         << ((pref[i][n] - pref[i][j]) + (time - j) * (psa[i][n] - psa[i][j]))
         << '\n';
  if (false)
    cerr << ("(pref[i][n] - pref[i][j])") << " is "
         << ((pref[i][n] - pref[i][j])) << '\n';
  if (false) cerr << "raising by " << time - j << '\n';
  if (false) cerr << val << " " << val2 << '\n';
  return max(val, val2);
}
signed main() {
  ios::sync_with_stdio(0);
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i <= 1; i++) {
    for (long long j = 1; j <= n; j++) {
      cin >> a[i][j];
      psa[i][j] = psa[i][j - 1] + a[i][j];
    }
  }
  for (long long i = 0; i <= 1; i++) {
    for (long long j = 1; j <= n; j++) {
      pref[i][j] = pref[i][j - 1] + a[i][j] * j;
      suf[i][n - j + 1] = suf[i][n - j + 2] + a[i][n - j + 1] * j;
    }
  }
  for (long long i = 0; i <= 1; i++) {
    for (long long j = 1; j <= n; j++) {
      if (false) cerr << suf[i][j] << " ";
    }
    if (false) cerr << '\n';
  }
  cout << f(0, 1, 0) << '\n';
}
