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 maxn = 3e5 + 9;
long long a[maxn], b[maxn], Sa[maxn], Sb[maxn], Fa[maxn], Fb[maxn], Qa[maxn],
    Qb[maxn], W[maxn];
long long max(long long a, long long b) { return a > b ? a : b; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &b[i]);
  }
  for (int i = 1; i <= n; ++i) {
    Sa[i] = Sa[i - 1] + a[i];
    Sb[i] = Sb[i - 1] + b[i];
    Fa[i] = Fa[i - 1] + (i - 1) * a[i];
    Fb[i] = Fb[i - 1] + (i - 1) * b[i];
  }
  for (int i = n, j = 0; i; --i, ++j) {
    Qa[i] = Qa[i + 1] + j * a[i];
    Qb[i] = Qb[i + 1] + j * b[i];
  }
  long long ans = Fa[n] + Qb[1] + n * Sb[n];
  for (int i = 1, j = 0; i <= n; ++i, j += 2) {
    if (i & 1) {
      W[i] = W[i - 1] + j * a[i] + (j + 1) * b[i];
      ans = max(ans, W[i] + Fb[n] - Fb[i] + (j - i + 2) * (Sb[n] - Sb[i]) +
                         Qa[i + 1] + (n + i) * (Sa[n] - Sa[i]));
    } else {
      W[i] = W[i - 1] + j * b[i] + (j + 1) * a[i];
      ans = max(ans, W[i] + Fa[n] - Fa[i] + (j - i + 2) * (Sa[n] - Sa[i]) +
                         Qb[i + 1] + (n + i) * (Sb[n] - Sb[i]));
    }
  }
  printf("%lld", ans);
  return 0;
}
