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 mod = 1e9 + 7;
long long qpow(long long x, long long k) {
  return k == 0 ? 1
                : 1ll * qpow(1ll * x * x % mod, k >> 1) * (k & 1 ? x : 1) % mod;
}
const int Maxn = 3e5 + 5;
int n;
int a[Maxn], b[Maxn];
long long suma[Maxn], sumb[Maxn];
long long suf1[Maxn], suf2[Maxn];
int c;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= n; i++) scanf("%d", b + i);
  for (int i = 1; i <= n; i++) {
    suma[i] = suma[i - 1] + a[i];
    sumb[i] = sumb[i - 1] + b[i];
  }
  suf1[1] = 0;
  c = 0;
  for (int i = 1; i <= n; i++) {
    suf1[1] += (long long)c * a[i];
    c++;
  }
  for (int i = n; i >= 1; i--) {
    suf1[1] += (long long)c * b[i];
    c++;
  }
  for (int i = 3; i <= n; i += 2) {
    suf1[i] = suf1[i - 2];
    suf1[i] -= (long long)((i - 3) * 2) * a[i - 2];
    suf1[i] -= (long long)((i - 3) * 2 + 1) * a[i - 1];
    suf1[i] -= (long long)(2 * n - 1) * b[i - 2];
    suf1[i] -= (long long)(2 * n - 2) * b[i - 1];
    suf1[i] += (suma[n] - suma[i - 1]) * 2;
    suf1[i] += (sumb[n] - sumb[i - 1]) * 2;
  }
  suf2[2] = 0;
  c = 2;
  for (int i = 2; i <= n; i++) {
    suf2[2] += (long long)c * b[i];
    c++;
  }
  for (int i = n; i >= 2; i--) {
    suf2[2] += (long long)c * a[i];
    c++;
  }
  for (int i = 4; i <= n; i += 2) {
    suf2[i] = suf2[i - 1];
    suf2[i] -= (long long)((i - 3) * 2) * b[i - 2];
    suf2[i] -= (long long)((i - 3) * 2 + 1) * b[i - 1];
    suf2[i] -= (long long)(2 * n - 1) * a[i - 2];
    suf2[i] -= (long long)(2 * n - 2) * a[i - 1];
    suf2[i] += (suma[n] - suma[i - 1]) * 2;
    suf2[i] += (sumb[n] - sumb[i - 1]) * 2;
  }
  long long ans = 0;
  long long cur = 0;
  c = 0;
  for (int i = 1; i <= n; i++) {
    if (i & 1) {
      ans = max(ans, cur + suf1[i]);
      cur += (long long)c * a[i];
      c++;
      cur += (long long)c * b[i];
      c++;
    } else {
      ans = max(ans, cur + suf2[i]);
      cur += (long long)c * b[i];
      c++;
      cur += (long long)c * a[i];
      c++;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
