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 N = 300004;
long long n, a[N], b[N];
long long hor[N], zig[N];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  hor[0] = 0;
  for (int i = 0; i < n; i++) hor[0] += (a[i] + b[i]);
  for (int i = 1; i < n; i++) hor[i] = hor[i - 1] - a[i - 1] - b[i - 1];
  hor[0] = 0;
  hor[1] *= 2;
  for (int i = 0; i < n; i++) hor[0] += (i * a[i] + (2 * n - 1 - i) * b[i]);
  for (int i = 1; i < n; i++)
    hor[1] += ((i - 1) * b[i] + (2 * n - 2 - i) * a[i]);
  for (int i = 2; i < n; i++) {
    hor[i] = hor[i - 2] + 2 * hor[i];
    if (i & 1)
      hor[i] -= ((2 * i - 4) * b[i - 2] + (2 * i - 3) * b[i - 1] +
                 (2 * n - 2) * a[i - 1] + (2 * n - 1) * a[i - 2]);
    else
      hor[i] -= ((2 * i - 4) * a[i - 2] + (2 * i - 3) * a[i - 1] +
                 (2 * n - 2) * b[i - 1] + (2 * n - 1) * b[i - 2]);
  }
  zig[0] = 0 * a[0] + 1 * b[0];
  for (int i = 1; i < n; i++) {
    if (i & 1)
      zig[i] = 2 * i * b[i] + (2 * i + 1) * a[i] + zig[i - 1];
    else
      zig[i] = 2 * i * a[i] + (2 * i + 1) * b[i] + zig[i - 1];
  }
  long long ans = max(zig[n - 1], hor[0]);
  for (int i = 0; i < n - 1; i++) ans = max(ans, zig[i] + hor[i + 1]);
  cout << ans;
}
