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 qian[1000001], houj[1000001], houo[1000001], mg[3][1000001];
int sum2[1000001], g[1000001];
int main() {
  int n;
  cin >> n;
  int n1 = n, n2 = n - 1;
  int sum1 = 0;
  int max = 0;
  int f1 = 0, f2 = 2 * n - 1, fq = 0, tot = 1;
  for (int i = 1; i <= 2; i++)
    for (int u = 1; u <= n; u++) {
      cin >> mg[i][u];
      if (i == 1) {
        sum1 += mg[i][u] * f1;
        f1++;
      }
      if (i == 2) {
        sum1 += mg[i][u] * f2;
        f2--;
      }
    }
  for (int i = 1; i <= n; i++) {
    if (i % 2 != 0) {
      qian[i] += mg[1][i] * fq;
      fq++;
      qian[i] += mg[2][i] * fq;
      fq++;
    } else {
      qian[i] += mg[2][i] * fq;
      fq++;
      qian[i] += mg[1][i] * fq;
      fq++;
    }
    qian[i] += qian[i - 1];
  }
  for (int i = n; i >= 1; i--) {
    houj[i] = mg[1][i] * n1 + mg[2][i] * n2 + houj[i + 1];
    houo[i] = mg[1][i] * n2 + mg[2][i] * n1 + houo[i + 1];
    n1++;
    n2--;
    g[i] = mg[1][i] + mg[2][i] + g[i + 1];
  }
  for (int k = 1; k <= n; k++) {
    if (k % 2 != 0) {
      sum2[k] = qian[k] + houj[1 + k] + g[1 + k] * k;
    } else
      sum2[k] = qian[k] + houo[1 + k] + g[1 + k] * k;
    if (sum2[k] > max) {
      max = sum2[k];
    }
  }
  if (max > sum1)
    cout << max;
  else
    cout << sum1;
}
