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 MAX_N = 3e5 + 1;
int n, a[MAX_N], b[MAX_N];
long long sum_s[2 * MAX_N], sum_n[2 * MAX_N], sum_ab[MAX_N], sum_l[MAX_N],
    sum_r[MAX_N];
long long res;
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++) {
    sum_s[i] = sum_s[i - 1] + (i - 1) * a[i];
    sum_n[i] = sum_n[i - 1] + (i - 1) * b[i];
  }
  for (int i = n; i >= 1; i--) {
    sum_s[2 * n - i + 1] = sum_s[2 * n - i] + (2 * n - i) * b[i];
    sum_n[2 * n - i + 1] = sum_n[2 * n - i] + (2 * n - i) * a[i];
    sum_ab[i] = sum_ab[i + 1] + (a[i] + b[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (i % 2) {
      sum_r[i] = sum_s[2 * n - i + 1] - sum_s[i - 1] + (i - 1) * sum_ab[i];
      sum_l[i] = sum_l[i - 1] + (2 * i - 4) * b[i - 1] + (2 * i - 3) * a[i - 1];
    } else {
      sum_r[i] = sum_n[2 * n - i + 1] - sum_n[i - 1] + (i - 1) * sum_ab[i];
      sum_l[i] = sum_l[i - 1] + (2 * i - 4) * a[i - 1] + (2 * i - 3) * b[i - 1];
    }
  }
  for (int i = 1; i <= n; i++) {
    if (res < sum_l[i] + sum_r[i]) {
      res = sum_l[i] + sum_r[i];
    }
  }
  printf("%lld\n", res);
  return 0;
}
