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;
long long a[1000005], b[1000005], v1[1000005], v2[1000005], sum[1000005];
int main() {
  int i, n;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (i = 1; i <= n; i++) scanf("%lld", &b[i]);
  sum[n + 1] = v1[n + 1] = v2[n + 1] = 0;
  for (i = n; i >= 1; i--) {
    v1[i] = v1[i + 1] + sum[i + 1] + b[i] + a[i] * (n - i + 1) * 2;
    v2[i] = v2[i + 1] + sum[i + 1] + a[i] + b[i] * (n - i + 1) * 2;
    sum[i] = sum[i + 1] + a[i] + b[i];
  }
  long long nsum = 0, ans = v2[1];
  for (i = 1; i <= n; i++) {
    if (i & 1) {
      nsum += a[i] * (i * 2 - 2) + b[i] * (i * 2 - 1);
      ans = max(ans, nsum + v1[i + 1] + sum[i + 1] * (i * 2 - 1));
    } else {
      nsum += b[i] * (i * 2 - 2) + a[i] * (i * 2 - 1);
      ans = max(ans, nsum + v2[i + 1] + sum[i + 1] * (i * 2 - 1));
    }
  }
  printf("%lld\n", ans);
  return 0;
}
