#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long mod = (int)1e9 + 7;
const int N = 3e5 + 100;
int n;
long long a[N], b[N];
long long suma[N], sumb[N];
long long prea[N], preb[N];
long long sufa[N], sufb[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    suma[i] = a[i] + suma[i - 1];
    prea[i] = prea[i - 1] + a[i] * (i - 1);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &b[i]);
    sumb[i] = b[i] + sumb[i - 1];
    preb[i] = preb[i - 1] + b[i] * (i - 1);
  }
  for (int i = n; i >= 1; i--) {
    sufa[i] = sufa[i + 1] + a[i] * (n - i);
    sufb[i] = sufb[i + 1] + b[i] * (n - i);
  }
  long long ans = 0, tmp = 0;
  long long t = 0;
  int f = 0;
  for (int i = 1; i <= n; i++) {
    if (!f) {
      f = 1;
      long long len = n - i + 1;
      long long z = tmp + (suma[n] - suma[i - 1]) * (t - i + 1) + prea[n] -
                    prea[i - 1] + (t + len) * (sumb[n] - sumb[i - 1]) +
                    sufb[i] - sufb[n];
      ans = max(ans, z);
      tmp += t * a[i];
      t++;
      tmp += t * b[i];
      t++;
      z = tmp + (sumb[n] - sumb[i]) * (t - i) + preb[n] - preb[i] +
          (t + len - 1) * (suma[n] - suma[i]) + sufa[i + 1] - sufa[n];
      ans = max(ans, z);
    } else {
      f = 0;
      long long len = n - i + 1;
      long long z = tmp + (sumb[n] - sumb[i - 1]) * (t - i + 1) + preb[n] -
                    preb[i - 1] + (t + len) * (suma[n] - suma[i - 1]) +
                    sufa[i] - sufa[n];
      ans = max(ans, z);
      tmp += t * b[i];
      t++;
      tmp += t * a[i];
      t++;
      z = tmp + (suma[n] - suma[i]) * (t - i + 1) + sufa[n] - sufa[i] +
          (t + len - 1) * (sumb[n] - sumb[i]) + sufb[i + 1] - sufb[n];
      ans = max(ans, z);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
