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;
vector<long long> a, b, o, felulrol, felulrol2, alulrol, alulrol2;
int n;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  a.resize(n + 1);
  b.resize(n + 1);
  o.resize(n + 1);
  felulrol.resize(n + 1);
  felulrol2.resize(n + 1);
  alulrol.resize(n + 1);
  alulrol2.resize(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int k = n - 1; k >= 0; k--) {
    o[k] = o[k + 1] + a[k] + b[k];
  }
  long long m = 0;
  for (int k = n - 1; k >= 0; k--) {
    felulrol[k] = (2 * m + 1) * b[k] + felulrol[k + 1] + o[k + 1];
    m++;
  }
  for (int k = 0; k < n; k++) {
    felulrol2[k] = felulrol[k] + 2 * k * o[k];
  }
  m = 0;
  for (int k = n - 1; k >= 0; k--) {
    alulrol[k] = (2 * m + 1) * a[k] + alulrol[k + 1] + o[k + 1];
    m++;
  }
  for (int k = 0; k < n; k++) {
    alulrol2[k] = alulrol[k] + 2 * k * o[k];
  }
  vector<long long> bo(n);
  for (int k = 0; k < n; k++) {
    if (k != 0) {
      if (k % 2 == 0) {
        bo[k] = bo[k - 1] + a[k] * (2 * k) + b[k] * (2 * k + 1);
      } else {
        bo[k] = bo[k - 1] + a[k] * (2 * k + 1) + b[k] * (2 * k);
      }
    } else {
      bo[0] = b[0];
    }
  }
  long long maximum = 0;
  for (int k = 0; k < n - 1; k++) {
    if (k % 2 == 0) {
      maximum = max((long long)bo[k] + alulrol2[k + 1], maximum);
    } else {
      maximum = max((long long)bo[k] + felulrol2[k + 1], maximum);
    }
  }
  cout << max(maximum, (long long)felulrol2[0]);
  return 0;
}
