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;
int n;
int a[2][300005];
long long s[300005];
long long t[300005];
long long u[300005];
long long P[300005];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  memset(a, 0, sizeof(a));
  for (int i = 1; i <= n; i++) cin >> a[0][i];
  for (int i = 1; i <= n; i++) cin >> a[1][i];
  memset(s, 0, sizeof(s));
  for (int i = 1; i <= n; i++) {
    if (i % 2 == 1)
      s[i] += s[i - 1] + (2 * i - 1) * a[0][i] + (2 * i) * a[1][i];
    else
      s[i] += s[i - 1] + (2 * i - 1) * a[1][i] + (2 * i) * a[0][i];
  }
  memset(P, 0, sizeof(P));
  for (int i = n; i >= 1; i--) {
    P[i] = P[i + 1] + a[0][i] + a[1][i];
  }
  memset(t, 0, sizeof(t));
  memset(u, 0, sizeof(u));
  for (int i = n; i >= 1; i--) {
    t[i] =
        (2 * (i - 1) + 1) * a[0][i] + (2 * n) * a[1][i] + t[i + 1] - P[i + 1];
    u[i] =
        (2 * (i - 1) + 1) * a[1][i] + (2 * n) * a[0][i] + t[i + 1] - P[i + 1];
  }
  long long m = 0;
  for (int i = 0; i <= n; i++) {
    if (i % 2 == 0)
      m = max(m, s[i] + t[i + 1]);
    else
      m = max(m, s[i] + u[i + 1]);
  }
  cout << m - P[1];
  return 0;
}
