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 MAXN = 3e5 + 7;
long long M[2][MAXN], dp1[MAXN], dp2[MAXN];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%lld", &M[i][j]);
    }
  }
  dp1[0] = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0)
      dp1[i + 1] = dp1[i] + (i * 2) * M[0][i] + (i * 2 + 1) * M[1][i];
    else
      dp1[i + 1] = dp1[i] + (i * 2 + 1) * M[0][i] + (i * 2) * M[1][i];
  }
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += M[0][i];
    dp2[0] += i * M[0][i];
    if (i) dp2[1] += (2 * n - i) * M[0][i];
  }
  for (int i = n - 1; i >= 0; i--) {
    sum += M[1][i];
    dp2[0] += (2 * n - i - 1) * M[1][i];
    if (i) dp2[1] += (i + 1) * M[1][i];
  }
  sum -= M[0][0] + M[1][0] + M[0][1] + M[1][1];
  for (int i = 2; i < n; i++) {
    if (i % 2 == 0)
      dp2[i] = dp2[i - 2] - (2 * n - 1) * M[1][i - 2] -
               (2 * n - 2) * M[1][i - 1] - (2 * (i - 2)) * M[0][i - 2] -
               (2 * (i - 2) + 1) * M[0][i - 1] + 2 * sum;
    else
      dp2[i] = dp2[i - 2] - (2 * n - 1) * M[0][i - 2] -
               (2 * n - 2) * M[0][i - 1] - (2 * (i - 2)) * M[1][i - 2] -
               (2 * (i - 2) + 1) * M[1][i - 1] + 2 * sum;
    sum -= M[0][i] + M[1][i];
  }
  long long res = 0;
  for (int i = 0; i <= n; i++) res = max(res, dp1[i] + dp2[i]);
  cout << res << endl;
  return 0;
}
