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 f[300005], ans, a[300005], b[300005], sum1[300005], sum2[300005],
    t1[300005], t2[300005], t3[300005], t4[300005], n;
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (long long i = n; i; i--)
    t2[i] = t2[i + 1] + a[i] * (2ll * n - i), sum1[i] = sum1[i + 1] + a[i],
    t1[i] += t1[i + 1] + a[i] * (i - 1);
  for (long long i = 1; i <= n; i++) scanf("%lld", &b[i]);
  for (long long i = n; i; i--)
    t4[i] = t4[i + 1] + b[i] * (2ll * n - i), sum2[i] = sum2[i + 1] + b[i],
    t3[i] += t3[i + 1] + b[i] * (i - 1);
  f[0] = 0;
  ans = t1[1] + t4[1];
  for (long long i = 1; i <= n; i++) {
    if (i & 1) {
      f[i] = f[i - 1] + a[i] * ((i << 1) - 2) + b[i] * ((i << 1) - 1);
      ans = max(ans,
                f[i] + i * (sum1[i + 1] + sum2[i + 1]) + t2[i + 1] + t3[i + 1]);
    } else {
      f[i] = f[i - 1] + a[i] * ((i << 1) - 1) + b[i] * ((i << 1) - 2);
      ans = max(ans,
                f[i] + i * (sum1[i + 1] + sum2[i + 1]) + t1[i + 1] + t4[i + 1]);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
