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 = 6e5 + 5;
long long n, a[N], b[N];
long long ans = 0;
long long sum[N];
long long sum_[N];
long long sum_inv[N];
long long suml[N], sumr[N];
long long sum_pre[N];
void init() {
  for (int i = n; i >= 1; i--) sum_pre[i] = sum_pre[i + 1] + a[i] + b[i];
  for (int i = 1; i <= n; i++) {
    sum_[i] = sum_[i - 1] + a[i] * (i - 1);
    sum_inv[i] = sum_inv[i - 1] + b[i] * (i - 1);
  }
  for (int i = n; i >= 1; i--) {
    sum_[2 * n - i + 1] = sum_[2 * n - i] + b[i] * (2 * n - i);
    sum_inv[2 * n - i + 1] = sum_inv[2 * n - i] + a[i] * (2 * n - i);
  }
  for (int i = 1; i <= n; i++) {
    if (i % 2) {
      sumr[i] = sum_[2 * n + 1 - i] - sum_[i - 1] + (i - 1) * sum_pre[i];
      suml[i] = suml[i - 1] + a[i - 1] * (2 * i - 3) + b[i - 1] * (2 * i - 4);
    } else {
      sumr[i] = sum_inv[2 * n + 1 - i] - sum_inv[i - 1] + (i - 1) * sum_pre[i];
      suml[i] = suml[i - 1] + a[i - 1] * (2 * i - 4) + b[i - 1] * (2 * i - 3);
    }
  }
}
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);
  init();
  for (int i = 1; i <= n; i++) ans = max(ans, suml[i] + sumr[i]);
  printf("%lld\n", ans);
}
