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;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
const double PI = acos(-1.0);
const long long INF = 1e9 + 47;
const long long LINF = INF * INF;
const int MAX = 3e5 + 47;
int n;
long long a[MAX];
long long b[MAX];
long long sa[MAX];
long long sb[MAX];
long long sra[MAX];
long long srb[MAX];
long long ca[MAX];
long long cb[MAX];
long long cra[MAX];
long long crb[MAX];
long long DP[MAX][2];
inline long long get(int pos, bool verh) {
  if (pos == n) return 0;
  if (DP[pos][verh] != -1) return DP[pos][verh];
  long long res = 0;
  if (verh)
    res =
        max(ca[pos] + crb[pos] + sb[pos] * (n - pos),
            b[pos] + get(pos + 1, verh ^ 1) + 2 * (sa[pos + 1] + sb[pos + 1]));
  else
    res = max(cra[pos] + cb[pos] + sa[pos] * (n - pos),
              get(pos + 1, verh ^ 1) + sa[pos + 1] + sb[pos + 1] * 2 + sa[pos]);
  return DP[pos][verh] = res;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = (0); i < (n); ++i) cin >> a[i];
  for (int i = (0); i < (n); ++i) cin >> b[i];
  sa[n - 1] = a[n - 1];
  for (int i = (n - 1) - 1; i >= (0); --i) sa[i] = sa[i + 1] + a[i];
  sb[n - 1] = b[n - 1];
  for (int i = (n - 1) - 1; i >= (0); --i) sb[i] = sb[i + 1] + b[i];
  sra[0] = a[0];
  for (int i = (1); i < (n); ++i) sra[i] = sra[i - 1] + a[i];
  srb[0] = b[0];
  for (int i = (1); i < (n); ++i) srb[i] = srb[i - 1] + b[i];
  ca[n - 1] = 0;
  for (int i = (n - 1) - 1; i >= (0); --i) ca[i] = ca[i + 1] + sa[i + 1];
  cb[n - 1] = 0;
  for (int i = (n - 1) - 1; i >= (0); --i) cb[i] = cb[i + 1] + sb[i + 1];
  cra[n - 1] = 0;
  for (int i = (n - 1) - 1; i >= (0); --i)
    cra[i] = cra[i + 1] + a[i] * (n - i - 1);
  crb[n - 1] = 0;
  for (int i = (n - 1) - 1; i >= (0); --i)
    crb[i] = crb[i + 1] + b[i] * (n - i - 1);
  memset(DP, -1, sizeof(DP));
  cout << get(0, 1) << endl;
  cerr << "Time elapsed : " << clock() / (double)CLOCKS_PER_SEC << endl;
  return 0;
}
