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;
const int N = 300500;
const int mod = 1e9 + 7;
const long long inf = 1e18;
long long n, m, q;
long long a[3][N];
long long f[3][N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= 2; ++i)
    for (int j = 1; j <= n; ++j) cin >> a[i][j];
  for (int i = n; i >= 1; --i) {
    for (int j = 1; j <= 2; ++j) f[j][i] += a[j][i] + f[j][i + 1];
  }
  int t = 0;
  long long ansup = 0, ansdown = 0;
  for (int i = 1; i <= n; ++i) {
    ansup += t * a[1][i];
    ansdown += t * a[2][i];
    t++;
  }
  for (int i = 1; i <= n; ++i) {
    ansup += t * a[2][n - i + 1];
    ansdown += t * a[1][n - i + 1];
    t++;
  }
  long long res = ansup;
  t = 0;
  int we_up = 1;
  long long cur = 0;
  for (int i = 1; i <= n; ++i) {
    if (we_up)
      res = max(res, ansup + cur);
    else
      res = max(res, ansdown + cur);
    if (we_up) {
      cur += a[1][i] * t;
      cur += a[2][i] * (t + 1);
    } else {
      cur += a[2][i] * t;
      cur += a[1][i] * (t + 1);
    }
    ansup -= a[1][i] * (t);
    ansup -= a[2][i] * (n + n - 1);
    ansdown -= a[2][i] * (t);
    ansdown -= a[1][i] * (n + n - 1);
    t += 2;
    ansup += f[1][i + 1];
    ansup += f[2][i + 1];
    ansdown += f[2][i + 1];
    ansdown += f[1][i + 1];
    we_up ^= 1;
  }
  res = max(res, cur);
  cout << res;
  return 0;
}
