#include <bits/stdc++.h>
using namespace std;
long long a[2][300005], kum[2][300005], z[300005];
int main() {
  int n;
  cin >> n;
  long long sve = 0;
  for (int i = 0; i < 2; ++i) {
    for (int j = 1; j <= n; ++j) {
      cin >> a[i][j];
      sve += a[i][j];
    }
  }
  for (int i = n; i >= 1; --i) {
    z[i] = z[i + 1] + a[0][i] + a[1][i];
  }
  for (int i = n; i >= 1; --i) {
    for (int j = 0; j < 2; ++j) {
      kum[j][i] =
          kum[j][i + 1] + a[j][i] + a[j ^ 1][i] * (n - i + 1) * 2 + z[i + 1];
    }
  }
  bool sad = 0;
  long long ans = 0, val = 0;
  for (int i = 1; i <= n; ++i) {
    ans = max(ans, val + kum[sad][i] + (i - 1) * 2 * z[i]);
    val += (a[sad][i] * (i * 2 - 1) + a[sad ^ 1][i] * (i * 2));
    sad ^= 1;
  }
  cout << ans - sve;
  return 0;
}
