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 + 10;
long long dp[MAXn], dp2[MAXn][2], hp[MAXn], row1[MAXn], row2[MAXn], n, ans;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> row1[i];
  for (int i = 0; i < n; i++) cin >> row2[i];
  for (int i = n - 1; i >= 0; i--) hp[i] = row1[i] + row2[i] + hp[i + 1];
  dp2[n - 1][0] = row2[n - 1];
  dp2[n - 1][1] = row1[n - 1];
  for (long long i = n - 2; i >= 0; i--) {
    dp2[i][0] = hp[i + 1] + dp2[i + 1][0] + (row2[i] * ((n - i - 1) * 2 + 1));
    dp2[i][1] = hp[i + 1] + dp2[i + 1][1] + (row1[i] * ((n - i - 1) * 2 + 1));
  }
  dp[0] = row2[0];
  for (long long i = 1; i < n; i++) {
    if (i % 2) {
      dp[i] = dp[i - 1] + (row2[i] * 2 * (i)) + (row1[i] * (2 * (i) + 1));
    } else {
      dp[i] = dp[i - 1] + (row1[i] * 2 * (i)) + (row2[i] * (2 * (i) + 1));
    }
  }
  ans = dp2[0][0];
  for (int i = 0; i < n; i++)
    ans =
        max(ans, dp[i] + (dp2[i + 1][(i + 1) % 2] + hp[i + 1] * (2 * (i + 1))));
  cout << ans;
}
