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 = int(1e6) + 100;
const int mod = 998244353;
long long a[maxn], b[maxn];
long long sum[maxn], suma[maxn], sumb[maxn], sumc[maxn];
int n;
void init() {
  for (int i = n; i >= 1; i--) sum[i] = sum[i + 1] + a[i] + b[i];
  for (int i = n, j = n; i >= 1; i--, j++)
    suma[i] = suma[i + 1] + (i - 1) * a[i] + j * b[i];
  for (int i = n, j = n + 1; i >= 2; i--, j++)
    sumb[i] = sumb[i + 1] + i * b[i] + j * a[i];
  sumb[1] = sumb[2] + b[1];
  long long tol = 0, ret = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2 == 1) {
      ret += tol * a[i];
      tol++;
      ret += tol * b[i];
      tol++;
      sumc[i] = ret;
    } else {
      ret += tol * b[i];
      tol++;
      ret += tol * a[i];
      tol++;
      sumc[i] = ret;
    }
  }
}
int main() {
  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]);
  init();
  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    if (i % 2 == 0) {
      ans = max(ans, sumc[i] + suma[i + 1] + i * sum[i + 1]);
    } else {
      ans = max(ans, sumc[i] + sumb[i + 1] + (i - 1) * sum[i + 1]);
    }
  }
  printf("%lld\n", ans);
}
