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>
int n;
int a[300005] = {0}, b[300005] = {0};
long long aa[300005] = {0}, bb[300005] = {0};
long long add1[300005] = {0}, add2[300005] = {0};
int main() {
  long long temp = 0;
  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) {
    aa[i] = aa[i + 1] + long long(a[i]) * i;
    add1[i] = add1[i + 1] + long long(a[i]);
    bb[i] = bb[i + 1] + long long(b[i]) * (2 * n - 1 - i);
    add2[i] = add2[i + 1] + long long(b[i]);
  }
  long long left = 0, ans = aa[0] + bb[0], right;
  long long id = 0;
  for (int t = 2; t < n; t += 2) {
    left = left + a[t - 2] * id + a[t - 1] * (id + 1) + b[t - 2] * (id + 3) +
           b[t - 1] * (id + 2);
    right = (aa[t] + bb[t]) + long long(add1[t] + add2[t]) * t;
    if (left + right > ans) ans = left + right;
  }
  printf("%lld", ans);
  return 0;
}
