#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 3e5 + 100;
int a[2][maxn];
int n;
long long ans = 0;
long long sum[2][maxn];
long long f[2][2][maxn];
long long calc1(int x) {
  if (x > n) return -0x3f3f3f3f3f3f3f3fLL;
  return f[0][0][x] + f[1][1][x];
}
long long calc2(int x) {
  if (x > n) return -0x3f3f3f3f3f3f3f3fLL;
  return f[1][0][x] + f[0][1][x];
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[0][i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[1][i];
  }
  for (int i = 1; i <= n; i++) {
    sum[0][i] = sum[0][i - 1] + a[0][i];
    sum[1][i] = sum[1][i - 1] + a[1][i];
  }
  for (int i = n; i >= 1; i--) {
    f[0][0][i] = f[0][0][i + 1] + sum[0][n] - sum[0][i - 1];
    f[0][1][i] = f[0][1][i + 1] + sum[1][n] - sum[1][i - 1];
    f[1][1][i] = f[1][1][i + 1] + 1LL * (n - i + 1) * a[1][i];
    f[1][0][i] = f[1][0][i + 1] + 1LL * (n - i + 1) * a[0][i];
  }
  for (int i = 1; i <= n; i++) {
  }
  long long cnt = 0;
  long long temp_sum = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2) {
      ans =
          max(ans, temp_sum + calc1(i) +
                       (sum[0][n] - sum[0][i - 1] + sum[1][n] - sum[1][i - 1]) *
                           (cnt - 1) +
                       (sum[1][n] - sum[1][i - 1]) * (n - i + 1));
      temp_sum += cnt * a[0][i];
      cnt++;
      temp_sum += cnt * a[1][i];
      cnt++;
    } else {
      ans =
          max(ans, temp_sum + calc2(i) +
                       (sum[0][n] - sum[0][i - 1] + sum[1][n] - sum[1][i - 1]) *
                           (cnt - 1) +
                       (sum[0][n] - sum[0][i - 1]) * (n - i + 1));
      temp_sum += cnt * a[1][i];
      cnt++;
      temp_sum += cnt * a[0][i];
      cnt++;
    }
  }
  cout << max(ans, temp_sum) << endl;
  return 0;
}
