#include <bits/stdc++.h>
using namespace std;
const int maxn = 6e5 + 100;
long long a[maxn], b[maxn];
long long sum_per[maxn];
long long sum_s[maxn];
long long sum_n[maxn];
long long suml[maxn];
long long sumr[maxn];
int n;
void fun() {
  for (int i = n; i >= 1; i--) sum_per[i] = sum_per[i + 1] + a[i] + b[i];
  for (int i = 1; i <= n; i++)
    sum_s[i] = sum_s[i - 1] + a[i] * (i - 1),
    sum_n[i] = sum_n[i - 1] + b[i] * (i - 1);
  for (int i = n; i >= 1; i--)
    sum_s[2 * n - i + 1] = sum_s[2 * n - i] + b[i] * (2 * n - i),
                      sum_n[2 * n - i + 1] =
                          sum_n[2 * n - i] + a[i] * (2 * n - i);
  for (int i = 1; i <= n; i++) {
    if (i % 2) {
      sumr[i] = sum_s[2 * n + 1 - i] - sum_s[i - 1] + (i - 1) * sum_per[i];
      suml[i] = suml[i - 1] + a[i - 1] * (2 * i - 3) + b[i - 1] * (2 * i - 4);
    } else {
      sumr[i] = sum_n[2 * n + 1 - i] - sum_n[i - 1] + (i - 1) * sum_per[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("%lld", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%lld", &b[i]);
  fun();
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans = max(ans, suml[i] + sumr[i]);
  printf("%lld\n", ans);
  return 0;
}
