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 = 3e5 + 7;
int n;
long long int a[3][N], A[3][N], B[3][N], S[3][N];
void init() {
  for (int i = n, j = 0; i; --i, --j) A[1][i] = A[1][i + 1] + a[1][i] * j;
  for (int i = n, j = 1; i; --i, ++j) A[2][i] = A[2][i + 1] + a[2][i] * j;
  for (int i = n, j = 0; i; --i, --j) B[2][i] = B[2][i + 1] + a[2][i] * j;
  for (int i = n, j = 1; i; --i, ++j) B[1][i] = B[1][i + 1] + a[1][i] * j;
  for (int i = 1; i <= 2; ++i)
    for (int j = n; j; --j) S[i][j] = a[i][j] + S[i][j + 1];
}
long long int calc(long long int t, int j, int mat) {
  if (j > n) return 0ll;
  if (mat == 1) {
    int P = t + n - j;
    return A[1][j] + A[2][j] + (S[1][j] + S[2][j]) * P;
  } else {
    int P = t + n - j;
    return B[2][j] + B[1][j] + (S[1][j] + S[2][j]) * P;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie();
  cin >> n;
  for (int i = 1; i <= 2; ++i)
    for (int j = 1; j <= n; ++j) cin >> a[i][j];
  init();
  long long int ans = calc(0, 1, 1), sum = 0;
  for (int i = 1, mul = 0; i <= n; ++i, mul += 2) {
    if (i & 1) {
      sum += a[1][i] * mul;
      sum += a[2][i] * (mul + 1ll);
      long long int tmp = sum + calc(mul + 1ll, i + 1, 1);
      ans = max(ans, tmp);
    } else {
      sum += a[2][i] * mul;
      sum += a[1][i] * (mul + 1ll);
      long long int tmp = sum + calc(mul + 1ll, i + 1, 2);
      ans = max(ans, tmp);
    }
  }
  cout << ans << '\n';
  return 0;
}
