#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long llinf = (1LL << 61);
const int inf = (1 << 30);
const int nmax = 3e5 + 50;
const int mod = 1e9 + 7;
using namespace std;
long long n, a[2][nmax], b[nmax], c[nmax], d[nmax], e[nmax], s[5][nmax], sum, i,
    j, t, tmp, ans, nr = 1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 0; i < 2; i++)
    for (j = 1; j <= n; j++) cin >> a[i][j];
  for (i = 2; i <= n; i++) {
    sum += a[0][i];
    s[0][i] = sum;
    b[i] = b[i - 1] + sum;
  }
  for (i = n; i >= 1; i--) {
    sum += a[1][i];
    s[1][i] = sum;
    c[i] = c[i + 1] + sum;
    if (i == n) c[i] += b[n];
  }
  sum = 0;
  for (i = 1; i <= n; i++) {
    sum += a[1][i];
    s[2][i] = sum;
    d[i] = d[i - 1] + sum;
  }
  for (i = n; i >= 2; i--) {
    sum += a[0][i];
    s[3][i] = sum;
    e[i] = e[i + 1] + sum;
    if (i == n) e[i] += d[n];
  }
  sum = 0, i = 0, j = 1;
  for (t = 1;; t++) {
    if (i & 1) {
      tmp = c[j + 1] - b[j - 1] - s[0][j - 1] * (n - j + 1 + n - j) +
            (s[1][j + 1] - s[0][j - 1]) * (nr - 1);
      ans = max(ans, tmp + sum);
    } else {
      tmp = e[j + 1] - d[j - 1] - s[2][j - 1] * (n - j + 1 + n - j) +
            (s[3][j + 1] - s[2][j - 1]) * (nr - 1);
      ans = max(ans, tmp + sum);
    }
    i ^= 1;
    sum += nr * a[i][j] + (nr + 1) * a[i][j + 1];
    ans = max(ans, sum);
    nr += 2, j++;
    if (j > n) break;
  }
  cout << ans << endl;
  return 0;
}
