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;
void solve() {
  int64_t n;
  cin >> n;
  vector<int64_t> a[2];
  a[0].resize(n);
  a[1].resize(n);
  for (int i = 0; i < n; i++) cin >> a[0][i];
  for (int i = 0; i < n; i++) cin >> a[1][i];
  vector<int64_t> suf[2];
  suf[0].resize(n + 1);
  suf[1].resize(n + 1);
  for (int i = n - 1; i >= 0; i--) suf[0][i] = suf[0][i + 1] + a[0][i];
  for (int i = n - 1; i >= 0; i--) suf[1][i] = suf[1][i + 1] + a[1][i];
  vector<int64_t> pre[2];
  pre[0].resize(n + 1);
  pre[1].resize(n + 1);
  for (int i = 1; i <= n; i++) pre[0][i] = pre[0][i - 1] + a[0][i - 1];
  for (int i = 1; i <= n; i++) pre[1][i] = pre[1][i - 1] + a[1][i - 1];
  vector<int64_t> mult[2];
  mult[0].resize(n + 1);
  mult[1].resize(n + 1);
  for (int i = 1; i <= n; i++) mult[0][i] = mult[0][i - 1] + a[0][i - 1] * (i);
  for (int i = 1; i <= n; i++) mult[1][i] = mult[1][i - 1] + a[1][i - 1] * (i);
  vector<int64_t> rmult[2];
  rmult[0].resize(n + 1);
  rmult[1].resize(n + 1);
  for (int i = n - 1; i >= 0; i--)
    rmult[0][i] = rmult[0][i + 1] + a[0][i] * (n - i);
  for (int i = n - 1; i >= 0; i--)
    rmult[1][i] = rmult[1][i + 1] + a[1][i] * (n - i);
  int64_t res = mult[0][n] - 1 * suf[0][0] + rmult[1][0] + (n - 1) * suf[1][0];
  int64_t curr = a[0][0] * 0;
  for (int64_t i = 1; i < 2 * n; i += 4) {
    if (i / 2 + 1 >= a[0].size()) {
      res = max(res, curr + i * a[1][i / 2]);
      break;
    }
    res = max(res, curr + mult[1][n] - mult[1][i / 2] + i / 2 * suf[1][i / 2] +
                       rmult[0][i / 2 + 1] +
                       (i + n - (i / 2 + 1)) * suf[0][i / 2 + 1]);
    curr += a[1][i / 2] * i + a[1][i / 2 + 1] * (i + 1);
    if (i / 2 + 2 >= a[0].size()) {
      res = max(res, curr + (i + 2) * a[0][i / 2 + 1]);
      break;
    }
    res = max(res, curr + mult[0][n] - mult[0][i / 2 + 1] +
                       (i / 2 + 1) * suf[0][i / 2 + 1] + rmult[1][i / 2 + 2] +
                       (i + n - (i / 2 + 2)) * suf[1][i / 2 + 2]);
    curr += a[0][i / 2 + 1] * (i + 2) + a[0][i / 2 + 2] * (i + 3);
  }
  cout << res << endl;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
