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 = 1000000 + 7;
int n;
long long a[2][N];
long long pre[2][N], suf[2][N], sum[2][N];
long long ans, now, cur;
int main() {
  scanf("%d", &n);
  for (int j = 0; j < 2; ++j) {
    for (int i = 1; i <= n; ++i) scanf("%lld", a[j] + i);
    for (int i = n; i; --i)
      pre[j][i] = pre[j][i + 1] + a[j][i] * i,
      suf[j][i] = suf[j][i + 1] + a[j][i] * (n - i + 1),
      sum[j][i] = sum[j][i + 1] + a[j][i];
  }
  for (int k = -1, j = 0, i = 0; i <= n; k++ & 1 ? ++i : j ^= 1) {
    cur += a[j][i] * k;
    if (k & 1)
      ans = max(ans, cur + pre[j][i + 1] + (k - i) * sum[j][i + 1] +
                         suf[j ^ 1][i + 1] + (k + n - i) * sum[j ^ 1][i + 1]);
  }
  ans = max(ans, cur);
  printf("%lld", ans);
  return 0;
}
