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 a[3][300005], tot[3][300005], dp[3][300005], suma[300005];
int main() {
  long long ans, n, i, sum, nr;
  cin >> n;
  if (n == 1) {
    long long a, b;
    cin >> a >> b;
    cout << b << '\n';
    return 0;
  }
  for (i = 1; i <= n; i++) cin >> a[1][i];
  for (i = 1; i <= n; i++) cin >> a[2][i];
  sum = a[1][n] + a[2][n];
  suma[n] = sum;
  tot[1][n] = a[2][n] * 2 + a[1][n];
  tot[2][n] = a[1][n] * 2 + a[2][n];
  for (i = n - 1; i >= 1; i--) {
    tot[1][i] = tot[1][i + 1] + sum + a[1][i] + a[2][i] * ((n - i) * 2 + 2);
    tot[2][i] = tot[2][i + 1] + sum + a[2][i] + a[1][i] * ((n - i) * 2 + 2);
    sum += a[1][i] + a[2][i];
    suma[i] = sum;
  }
  ans =
      max(tot[1][2] + a[2][1] * (n * 2 - 1), tot[2][2] + suma[2] + a[2][1] * 1);
  dp[1][1] = 0;
  dp[2][1] = a[2][1];
  nr = 2;
  for (i = 2; i <= n; i++) {
    dp[1][i] = dp[2][i - 1] + a[2][i] * nr + (a[1][i]) * (nr + 1);
    dp[2][i] = dp[1][i - 1] + a[1][i] * nr + (a[2][i]) * (nr + 1);
    nr += 2;
    ans = max(ans, dp[1][i] + tot[1][i + 1] + suma[i + 1] * (nr - 1));
    ans = max(ans, dp[2][i] + tot[2][i + 1] + suma[i + 1] * (nr - 1));
  }
  cout << ans << '\n';
  return 0;
}
