#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
long long sum1[maxn], sum2[maxn], a[maxn], b[maxn], sum3[maxn], sum4[maxn];
int main() {
  int n, i, j, k;
  cin >> n;
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (i = 1; i <= n; i++) scanf("%lld", &b[i]);
  for (i = 1; i <= n; i++) {
    if (i & 1) {
      sum1[i] = (i * 2 - 2) * a[i] + (i * 2 - 1) * b[i];
    } else {
      sum1[i] = (i * 2 - 2) * b[i] + (i * 2 - 1) * a[i];
    }
    sum1[i] += sum1[i - 1];
  }
  for (i = n; ~i; i--) {
    sum3[i] += a[i] + b[i];
    sum3[i] += sum3[i + 1];
  }
  for (i = n; i; i--) {
    sum2[i] += sum2[i + 1] + sum3[i + 1];
    sum2[i] += b[i] * ((n - i + 1) * 2 - 1);
    sum4[i] += sum4[i + 1] + sum3[i + 1];
    sum4[i] += a[i] * ((n - i + 1) * 2 - 1);
  }
  long long ans = 0;
  for (i = 0; i <= n; i++) {
    long long t = sum1[i];
    if (i & 1) {
      t += sum4[i + 1] + sum3[i + 1] * (i)*2;
    } else
      t += sum2[i + 1] + sum3[i + 1] * i * 2;
    ans = max(ans, t);
  }
  cout << ans << endl;
  return 0;
}
