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;
const int INF = 0x3f3f3f3f;
int n;
long long ans;
long long a[N + 10], b[N + 10];
long long c[N + 10][3];
long long apre[N + 10], bpre[N + 10];
long long asum[N + 10], bsum[N + 10];
long long asuc[N + 10], bsuc[N + 10];
long long sum, rec;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++) sum += a[i] + b[i];
  for (int i = 1; i <= n; i++) {
    if (i & 1) {
      c[i][1] = c[i - 1][1] + a[i] * (2 * i - 1);
      c[i][2] = c[i][1] + b[i] * 2 * i;
    } else {
      c[i][2] = c[i - 1][2] + b[i] * (2 * i - 1);
      c[i][1] = c[i][2] + a[i] * 2 * i;
    }
  }
  rec = 0;
  for (int i = n; i; i--) {
    rec += a[i];
    asum[i] = asum[i + 1] + a[i];
    apre[i] = apre[i + 1] + rec;
    asuc[i] = asuc[i + 1] + a[i] * (n - i + 1);
  }
  rec = 0;
  for (int i = n; i; i--) {
    rec += b[i];
    bsum[i] = bsum[i + 1] + b[i];
    bpre[i] = bpre[i + 1] + rec;
    bsuc[i] = bsuc[i + 1] + b[i] * (n - i + 1);
  }
  for (int i = 1; i <= n; i++) {
    if (i & 1) {
      long long res = c[i - 1][1] + apre[i] + asum[i] * (i - 1) * 2;
      int len = n + i - 2;
      res = res + bsum[i] * (len + 1) + bsuc[i];
      ans = max(ans, res);
      res = c[i][2] + bpre[i + 1] + bsum[i + 1] * i * 2;
      len = n + i - 1;
      res = res + asum[i + 1] * (len + 1) + asuc[i + 1];
      ans = max(ans, res);
    } else {
      long long res = c[i - 1][2] + bpre[i] + bsum[i] * (i - 1) * 2;
      int len = n + i - 2;
      res = res + asum[i] * (len + 1) + asuc[i];
      ans = max(ans, res);
      res = c[i][1] + apre[i + 1] + asum[i + 1] * i * 2;
      len = n + i - 1;
      res = res + bsum[i + 1] * (len + 1) + bsuc[i + 1];
      ans = max(ans, res);
    }
  }
  cout << ans - sum;
  return 0;
}
