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;
ifstream in("date.in");
ofstream out("date.out");
int mat[3][400001], pas[3][400005], d[400005], sum[400005], k, n, maxim;
int main(void) {
  cin >> n;
  for (int i = 1; i <= 2; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> mat[i][j];
    }
  }
  k = -1;
  for (int j = 1; j <= n; j++) {
    if (j % 2 == 1) {
      pas[1][j] = ++k;
      pas[2][j] = ++k;
    }
    if (j % 2 == 0) {
      pas[2][j] = ++k;
      pas[1][j] = ++k;
    }
  }
  for (int j = 1; j <= n; j++) {
    d[0] += mat[1][j] * (j - 1) + mat[2][j] * (n + (n - j + 1) - 1);
  }
  d[1] += mat[1][1] * pas[1][1] + mat[2][1] * pas[2][1];
  for (int j = 2; j <= n; j++) {
    d[1] += mat[2][j] * j;
  }
  k = n;
  for (int j = n; j >= 2; j--) {
    d[1] += mat[1][j] * ++k;
  }
  for (int j = n; j >= 1; j--) {
    sum[j] = sum[j + 1] + mat[1][j] + mat[2][j];
  }
  for (int j = 2; j <= n; j += 2) {
    d[j] = d[j - 2] + mat[1][j - 1] * pas[1][j - 1] -
           mat[1][j - 1] * ((j - 2) * 2) + mat[2][j - 1] * pas[2][j - 1] -
           mat[2][j - 1] * (n * 2 - 1) + mat[1][j] * pas[1][j] -
           mat[1][j] * ((j - 2) * 2 + 1) + mat[2][j] * pas[2][j] -
           mat[2][j] * (n * 2 - 2) + sum[j + 1] * 2;
  }
  for (int j = 3; j <= n; j += 2) {
    d[j] = d[j - 2] + mat[1][j - 1] * pas[1][j - 1] -
           mat[1][j - 1] * (n * 2 - 1) + mat[2][j - 1] * pas[2][j - 1] -
           mat[2][j - 1] * ((j - 2) * 2) + mat[1][j] * pas[1][j] -
           mat[1][j] * (n * 2 - 2) + mat[2][j] * pas[2][j] -
           mat[2][j] * ((j - 2) * 2 + 1) + sum[j + 1] * 2;
  }
  for (int i = 0; i <= n; i++) {
    maxim = max(maxim, d[i]);
  }
  cout << maxim;
  return 0;
}
