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[300005], b[300005], sa[300005], sb[300005];
long long read() {
  char c = getchar();
  long long x = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int main() {
  int n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i++) b[i] = read();
  sa[n] = a[n];
  for (int i = n - 1; i >= 1; i--) sa[i] = sa[i + 1] + a[i];
  sb[n] = b[n];
  for (int i = n - 1; i >= 1; i--) sb[i] = sb[i + 1] + b[i];
  long long ans = 0, s;
  s = 0;
  for (int i = 1; i <= n; i++) s += a[i] * (i - 1);
  for (int i = 1; i <= n; i++) s += b[i] * (2 * n - i);
  ans = max(ans, s);
  for (int i = 3; i <= n; i += 2) {
    s += (sa[i - 1] + sb[i]) * 2;
    s += b[i - 2] * (2 * i - 2 * n - 4);
    s += b[i - 1] * (2 * i - 2 * n - 2);
    ans = max(ans, s);
  }
  s = 0;
  for (int i = 1; i <= n; i++) s += b[i] * i;
  for (int i = 2; i <= n; i++) s += a[i] * (2 * n + 1 - i);
  ans = max(ans, s);
  for (int i = 4; i <= n; i += 2) {
    s += (sa[i] + sb[i - 1]) * 2;
    s += a[i - 2] * (2 * i - 2 * n - 4);
    s += a[i - 1] * (2 * i - 2 * n - 2);
    ans = max(ans, s);
  }
  printf("%lld\n", ans);
  return 0;
}
