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;
int n;
long long a[2][300005], sum[300005], dp[2][300005], ans, s, t;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[0][i];
  for (int i = 0; i < n; i++) cin >> a[1][i];
  for (int i = n - 1; i >= 0; i--) sum[i] = sum[i + 1] + a[0][i] + a[1][i];
  if ((n - 1) % 2 == 0)
    dp[0][n - 1] = a[1][n - 1];
  else
    dp[0][n - 1] = a[0][n - 1];
  if ((n - 1) % 2 != 0)
    dp[1][n - 1] = a[1][n - 1];
  else
    dp[1][n - 1] = a[0][n - 1];
  for (int i = n - 2; i >= 0; i--) {
    dp[0][i] = dp[0][i + 1] + sum[i] - a[0][i] + (n - i - 1) * 2 * a[1][i];
    dp[1][i] = dp[1][i + 1] + sum[i] - a[1][i] + (n - i - 1) * 2 * a[0][i];
  }
  for (int i = 0; i < n; i++) {
    ans = max(s + dp[i % 2][i], ans);
    if (i % 2 == 0)
      s += a[0][i] * t + a[1][i] * (t + 1);
    else
      s += a[1][i] * t + a[0][i] * (t + 1);
    t += 2;
    ans = max(s + dp[(i + 1) % 2][i + 1], ans);
  }
  cout << ans << endl;
  return 0;
}
