#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
int a[N], b[N];
long long aflat[N], bflat[N], aup[N], bup[N], adown[N], bdown[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", b + i);
  }
  for (int i = n - 1; i >= 0; i--) {
    aflat[i] = a[i] + aflat[i + 1];
    bflat[i] = b[i] + bflat[i + 1];
    aup[i] = aflat[i] + aup[i + 1];
    bup[i] = bflat[i] + bup[i + 1];
    adown[i] = a[i] * 1LL * (n - i) + adown[i + 1];
    bdown[i] = b[i] * 1LL * (n - i) + bdown[i + 1];
  }
  long long ans = 0;
  int times = 0;
  long long cur = 0;
  for (int j = 0; j < n; j++) {
    if (j % 2 == 0) {
      for (int i = 0; i < 2; i++) {
        if (i == 0) {
          long long res = aup[j] + (j * 2 - 1) * aflat[j] + bdown[j] +
                          bflat[j] * (n + j - 1);
          ans = max(ans, cur + res);
          cur += a[j] * 1LL * times;
        } else {
          long long res = bup[j] + (j * 2) * bflat[j] + adown[j + 1] +
                          aflat[j + 1] * (n + j);
          ans = max(ans, cur + res);
          cur += b[j] * 1LL * times;
        }
        times++;
      }
    } else {
      for (int i = 1; i >= 0; i--) {
        if (i == 0) {
          long long res = aup[j] + (j * 2) * aflat[j] + bdown[j + 1] +
                          bflat[j + 1] * (n + j);
          ans = max(ans, cur + res);
          cur += a[j] * 1LL * times;
        } else {
          long long res = bup[j] + (j * 2 - 1) * bflat[j] + adown[j] +
                          aflat[j] * (n + j - 1);
          ans = max(ans, cur + res);
          cur += b[j] * 1LL * times;
        }
        times++;
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
