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 maxn = 3e5 + 5;
long long sum1[maxn], sum2[maxn], a[maxn], b[maxn], sum3[maxn], sum4[maxn];
int main() {
  int n, i, j, k;
  cin >> n;
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (i = 1; i <= n; i++) scanf("%lld", &b[i]);
  for (i = 1; i <= n; i++) {
    if (i & 1) {
      sum1[i] = (i * 2 - 2) * a[i] + (i * 2 - 1) * b[i];
    } else {
      sum1[i] = (i * 2 - 2) * b[i] + (i * 2 - 1) * a[i];
    }
    sum1[i] += sum1[i - 1];
  }
  for (i = n; ~i; i--) {
    sum3[i] += a[i] + b[i];
    sum3[i] += sum3[i + 1];
  }
  for (i = n; i; i--) {
    sum2[i] += sum2[i + 1] + sum3[i + 1];
    sum2[i] += b[i] * ((n - i + 1) * 2 - 1);
    sum4[i] += sum4[i + 1] + sum3[i + 1];
    sum4[i] += a[i] * ((n - i + 1) * 2 - 1);
  }
  long long ans = 0;
  for (i = 0; i <= n; i++) {
    long long t = sum1[i];
    if (i & 1) {
      t += sum4[i + 1] + sum3[i + 1] * (i)*2;
    } else
      t += sum2[i + 1] + sum3[i + 1] * i * 2;
    ans = max(ans, t);
  }
  cout << ans << endl;
  return 0;
}
