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 MX = 3e5 + 10;
long long a[2][MX];
long long cnt[2][2][MX];
long long dp[2][MX];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 0; i < 2; ++i)
    for (int j = 1; j <= n; ++j) cin >> a[i][j];
  long long sum[2] = {};
  for (int i = 0; i < 2; ++i)
    for (int j = n; j > 0; --j) {
      int steps = (j - 1) * 2;
      cnt[1][i][j] = cnt[1][i][j + 1] + sum[i] +
                     a[i][j] * (steps - 1 + (n - j + 1) * 2) - sum[i] * 2;
      cnt[0][i][j] = cnt[0][i][j + 1] + sum[i] + a[i][j] * steps - sum[i] * 2;
      sum[i] += a[i][j];
    }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) ans += a[0][i] * (i - 1);
  for (int i = n; i > 0; --i) ans += a[1][i] * (n + n - i);
  dp[1][1] = a[1][1];
  for (int i = 2; i <= n; ++i) {
    if (i & 1) {
      ans = max(ans, dp[0][i - 1] + cnt[0][0][i] + cnt[1][1][i]);
      dp[0][i] = dp[0][i - 1] + a[0][i] * (i - 1) * 2;
      dp[1][i] = dp[0][i] + a[1][i] * (2 * i - 1);
    } else {
      ans = max(ans, dp[1][i - 1] + cnt[0][1][i] + cnt[1][0][i]);
      dp[1][i] = dp[1][i - 1] + a[1][i] * (i - 1) * 2;
      dp[0][i] = dp[1][i] + a[0][i] * (2 * i - 1);
    }
  }
  cout << ans;
  return 0;
}
