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 = 300 * 1000 + 9;
int n;
int a[2][N];
long long sum123[2][N];
long long sum321[2][N];
long long sum111[2][N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < n; ++j) scanf("%d", &a[i][j]);
  for (int i = 0; i < 2; ++i)
    for (int j = n - 1; j >= 0; --j) {
      sum123[i][j] = sum123[i][j + 1] + (j + 1) * 1LL * a[i][j];
      sum321[i][j] = sum321[i][j + 1] + (n - j) * 1LL * a[i][j];
      sum111[i][j] = sum111[i][j + 1] + a[i][j];
    }
  long long res = 0, sum = 0;
  for (int i = 0, j = 0; j < n; ++j, i ^= 1) {
    long long nres = sum;
    nres += sum123[i][j] + j * 1LL * sum111[i][j];
    nres += sum321[i ^ 1][j] + (j + n) * 1LL * sum111[i ^ 1][j];
    res = max(res, nres);
    sum += a[i][j] * 1ll * (j + j + 1);
    sum += a[i ^ 1][j] * 1ll * (j + j + 2);
  }
  for (int j = 0; j < n; ++j) res -= a[0][j] + a[1][j];
  printf("%I64d\n", res);
  return 0;
}
