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 long long maxn = 1e6 + 20;
int n;
long long a[3][maxn];
long long f[3][maxn];
long long zheng[3][maxn], fu[3][maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[1][i]);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[2][i]);
  for (long long i = 1; i <= n; i++) {
    f[1][i] = f[1][i - 1] + a[1][i];
    f[2][i] = f[2][i - 1] + a[2][i];
    zheng[1][i] = zheng[1][i - 1] + i * a[1][i];
    zheng[2][i] = zheng[2][i - 1] + i * a[2][i];
  }
  for (long long i = n; i >= 1; i--) {
    fu[1][i] = fu[1][i + 1] + (n - i + 1) * a[1][i];
    fu[2][i] = fu[2][i + 1] + (n - i + 1) * a[2][i];
  }
  long long now = 0;
  long long ans = 0;
  long long t = 0;
  for (long long i = 1; i <= n; i += 2) {
    long long k = n - i + 1;
    long long A = t * a[1][i] + (zheng[2][n] - zheng[2][i - 1] +
                                 (t + 1 - i) * (f[2][n] - f[2][i - 1]));
    A += fu[1][i + 1] + (t + k) * (f[1][n] - f[1][i]);
    ans = max(ans, now + A);
    long long B =
        (zheng[1][n] - zheng[1][i - 1]) + (t - i) * (f[1][n] - f[1][i - 1]);
    B += fu[2][i] + (t + k - 1) * (f[2][n] - f[2][i - 1]);
    ans = max(ans, now + B);
    now += a[1][i] * t + a[2][i] * (t + 1) + a[2][i + 1] * (t + 2) +
           a[1][i + 1] * (t + 3);
    t += 4;
  }
  cout << ans;
  return 0;
}
