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 = 3e5 + 229;
const int M = 1e9 + 7;
const int rx[4] = {1, -1, 0, 0};
const int ry[4] = {0, 0, 1, -1};
const double eps = 0.000001;
int a[N], b[N];
long long s = 0, prec1[N], prec2[N], ot = 0, now = 0, it = 1;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  for (int i = n - 1; i >= 0; --i) {
    prec1[i] = prec1[i + 1];
    prec1[i] += s;
    prec1[i] += ((n - i) * 2 - 1) * b[i];
    s += a[i];
    s += b[i];
  }
  s = 0;
  for (int i = n - 1; i >= 0; --i) {
    prec2[i] = prec2[i + 1];
    prec2[i] += s;
    prec2[i] += ((n - i) * 2 - 1) * a[i];
    s += a[i];
    s += b[i];
  }
  s = 0;
  for (int i = 1; i < n; ++i) {
    s += a[i];
    s += b[i];
  }
  ot = max(ot, prec1[0]);
  now = b[0];
  for (int i = 1; i < n; ++i) {
    if (i % 2) {
      ot = max(ot, now + prec2[i] + s * it);
      now += b[i] * (it + 1);
      now += a[i] * (it + 2);
    } else {
      ot = max(ot, now + prec1[i] + s * it);
      now += a[i] * (it + 1);
      now += b[i] * (it + 2);
    }
    it += 2;
    s -= a[i];
    s -= b[i];
  }
  ot = max(ot, now);
  s = 0;
  it = 1;
  for (int i = 0; i < n; ++i) {
    s += it * b[i];
    ++it;
  }
  for (int i = n - 1; i; --i) {
    s += it * a[i];
    ++it;
  }
  ot = max(ot, s);
  cout << ot;
  return 0;
}
