#include <bits/stdc++.h>
using namespace std;
const long long M = 3e5 + 10;
long long n, t1, t2;
long long a[M], b[M], sum123[M], sum321[M], sum0[M], sum1[M] = {0};
int main() {
  cin >> n;
  long long current = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    current += a[i] * (i + 1);
    sum123[i + 1] = current;
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  current = 0;
  for (int i = n - 1; i >= 0; i--) {
    current += b[i] * (n - i);
    sum321[i + 1] = current;
  }
  sum0[1] = a[0];
  sum1[1] = b[0];
  for (int i = 1; i < n; i++) {
    sum0[i + 1] = a[i] + sum0[i];
    sum1[i + 1] = b[i] + sum1[i];
  }
  long long ans = 0;
  long long currentZ = 0;
  for (int i = 0; i <= n; i += 1) {
    if (i % 2 == 0) {
      ans =
          max(ans, currentZ + sum123[n] - sum123[i] + i * (sum0[n] - sum0[i]) +
                       sum321[i + 1] + (i * 2 + n - i) * (sum1[n] - sum1[i]));
    } else {
      ans = max(ans, currentZ + (sum0[n] - sum0[i]) * (n + 1 + i * 2 + n - i) -
                         (sum123[n] - sum123[i]) +
                         (n + 1 + i) * (sum1[n] - sum1[i]) - sum321[i + 1]);
    }
    if (i + 1 <= n) {
      if (i % 2 == 0) {
        currentZ += (2 * i + 1) * a[i] + (2 * i + 2) * b[i];
      } else {
        currentZ += (2 * i + 1) * b[i] + (2 * i + 2) * a[i];
      }
    }
  }
  cout << ans - sum0[n] - sum1[n];
}
