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;
long long int N;
long long int A[2][300005];
long long int M[2][300005];
long long int S[300005];
long long int res, ans;
int main() {
  cin >> N;
  for (long long int j = 0; j < 2; j++)
    for (long long int i = 0; i < N; i++) cin >> M[j][i];
  for (long long int i = N - 1; i >= 0; i--)
    S[i] = S[i + 1] + M[0][i] + M[1][i];
  for (long long int j = 0; j < 2; j++)
    for (long long int i = N - 1; i >= 0; i--)
      A[j][i] = A[j][i + 1] + S[i + 1] + M[(j + 1) % 2][i] * (2 * (N - i) - 1);
  ans = A[0][0];
  for (long long int i = 0; i < N; i++) {
    res += 2 * i * M[i % 2][i] + (2 * i + 1) * M[(i + 1) % 2][i];
    ans = max(ans, res + A[(i + 1) % 2][i + 1]);
  }
  cout << ans;
}
