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>
#pragma comment(linker, "/STACK:64000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
const int INF = 2e9 + 179, MOD = 1e9 + 7;
const long long int BIGINF = 2e18 + 179;
const long double EPS = 0.000001;
using namespace std;
const int MMM = 500001;
long long int a[MMM], b[MMM], n, s[MMM], u[MMM], d[MMM], ss[MMM], aa[MMM],
    ul[MMM], ur[MMM], dl[MMM], dr[MMM], bb[MMM];
long long int suma(int l, int r) { return aa[r] - aa[l - 1]; }
long long int sumb(int l, int r) { return bb[r] - bb[l - 1]; }
long long int sums(int l, int r) { return ss[r] - ss[l - 1]; }
int solve() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    s[i] += a[i];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> b[i];
    s[i] += b[i];
  }
  for (int i = 1; i <= n; ++i) {
    ss[i] = ss[i - 1] + s[i];
    aa[i] = aa[i - 1] + a[i];
    bb[i] = bb[i - 1] + b[i];
  }
  u[n] = b[n];
  d[n] = a[n];
  for (int i = n - 1; i >= 1; --i) {
    ur[i] = ur[i + 1] + suma(i + 1, n);
    dr[i] = dr[i + 1] + sumb(i + 1, n);
    ul[i] = ul[i + 1] + a[i] * (n - i);
    dl[i] = dl[i + 1] + b[i] * (n - i);
    u[i] = ur[i] + dl[i] + sumb(i, n) * (n - i + 1);
    u[i] = max(u[i], b[i] + d[i + 1] + sums(i + 1, n) * 2);
    d[i] = dr[i] + ul[i] + suma(i, n) * (n - i + 1);
    d[i] = max(d[i], a[i] + u[i + 1] + sums(i + 1, n) * 2);
  }
  cout << u[1] << endl;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(20);
  solve();
  return 0;
}
