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 sum[300005], sm[300005], tsum[300005], su[300005];
long long a[3][300005];
signed main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= 2; i++) {
    for (long long j = 1; j <= n; j++) cin >> a[i][j];
  }
  sum[n] = a[2][n];
  tsum[n] = a[1][n] + a[2][n];
  for (long long i = n - 1; i >= 1; i--) {
    tsum[i] = tsum[i + 1] + a[1][i] + a[2][i];
  }
  for (long long i = n - 1; i >= 1; i--) {
    sum[i] = sum[i + 1] + tsum[i + 1] + (2 * (n - i) + 1) * a[2][i];
  }
  sm[1] = a[2][1];
  for (long long i = 2; i <= n; i++) {
    if (i % 2 == 0)
      sm[i] = sm[i - 1] + (2 * i - 2) * a[2][i] + (2 * i - 1) * a[1][i];
    else
      sm[i] = sm[i - 1] + (2 * i - 2) * a[1][i] + (2 * i - 1) * a[2][i];
  }
  su[n] = a[1][n];
  for (long long i = n - 1; i >= 1; i--) {
    su[i] = su[i + 1] + tsum[i + 1] + (2 * (n - i) + 1) * a[1][i];
  }
  long long ans = sum[1];
  for (long long i = 3; i <= n; i += 2) {
    ans = max(ans, sm[i - 1] + (2 * i - 2) * tsum[i] + sum[i]);
  }
  for (long long i = 2; i <= n; i++) {
    ans = max(ans, sm[i]);
  }
  for (long long i = 2; i <= n; i += 2) {
    ans = max(ans, sm[i - 1] + (2 * i - 2) * tsum[i] + su[i]);
  }
  cout << ans;
}
