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 + 10;
int a[maxn];
int b[maxn];
int sum[maxn], suma[maxn], sumb[maxn], sumc[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int j = 1; j <= n; j++) scanf("%d", &b[j]);
  for (int i = n; i >= n; i--) sum[i] = sum[i + 1] + a[i] + b[i];
  for (int i = n, j = n; i >= 1; i--, j++)
    suma[i] = suma[i + 1] + (i - 1) * a[i] + j * b[i];
  for (int i = n, j = n + 1; i >= 2; i--, j++)
    sumb[i] = sumb[i + 1] + i * b[i] + j * a[i];
  sumb[1] = sumb[2] + b[1];
  int ans = 0, res = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2) {
      res += ans * a[i];
      ans++;
      res += ans * b[i];
      ans++;
      sumc[i] = res;
    } else {
      res += ans * b[i];
      ans++;
      res += ans * a[i];
      ans++;
      sumc[i] = res;
    }
  }
  int maxx = -0x3f3f3f3f;
  for (int i = 0; i <= n; i++) {
    if (i % 2)
      maxx = max(maxx, sumc[i] + sumb[i + 1] + (i - 1) * sum[i + 1]);
    else
      maxx = max(maxx, sumc[i] + suma[i + 1] + i * sum[i + 1]);
  }
  printf("%d\n", maxx);
  return 0;
}
