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;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  long long siz = (n + 1) / 2;
  vector<pair<long long, long long>> dp(siz);
  vector<long long> a(n), b(n);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  for (long long i = 0; i < n; ++i) cin >> b[i];
  vector<long long> sums(n);
  {
    sums[n - 1] = b[n - 1] + 2 * a[n - 1];
    long long nowsum = a[n - 1] + b[n - 1];
    for (long long i = n - 2; i >= 0; --i) {
      sums[i] = sums[i + 1] + nowsum + b[i] + (2 * n - 2 * i) * a[i];
      nowsum += a[i] + b[i];
    }
  }
  long long sum = 0, ne = 0;
  if (n % 2) {
    dp[siz - 1].second = dp[siz - 1].first = b[n - 1];
    sum = b[n - 1] + a[n - 1];
    ne = 2;
  } else {
    dp[siz - 1].first = a[n - 1] + 2 * b[n - 1] + 3 * b[n - 2];
    dp[siz - 1].second = b[n - 2] + 2 * b[n - 1] + 3 * a[n - 1];
    sum = a[n - 2] + a[n - 1] + b[n - 2] + b[n - 1];
    ne = 4;
  }
  for (long long i = siz - 2; i >= 0; --i) {
    dp[i].first = a[i * 2 + 1] + dp[i + 1].first + sum * 2 +
                  (ne + 2) * b[i * 2 + 1] + (ne + 3) * b[i * 2];
    dp[i].second =
        b[i * 2] + 2 * b[i * 2 + 1] +
        max(3 * a[i * 2 + 1] + 4 * sum + max(dp[i + 1].second, dp[i + 1].first),
            (ne + 3) * a[i * 2 + 1] + sums[i * 2 + 2] + sum * 2);
    sum += a[i * 2] + a[i * 2 + 1] + b[i * 2] + b[i * 2 + 1];
    ne += 4;
  }
  cout << max(dp[0].first, dp[0].second) << endl;
  return 0;
}
