6
12 8 12 17 20 5
17 4 8 8 8 4
 6
4 1 12 9 3 11
12 20 19 12 19 11
 1
1
1
 2
1 2
1 1
 1
7
5
 6
16 20 18 7 14 2
17 12 4 10 7 4

705
 917
 1
 9
 5
 741

#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] * (n - i) + adown[i + 1];
    bdown[i] = b[i] * (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;
}
