#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
int n;
long long a[maxn], b[maxn];
long long va[maxn], vb[maxn], right_a[maxn], right_b[maxn], left_a[maxn],
    left_b[maxn];
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++) right_a[i] = 1ll * (i - 1) * a[i];
  for (int i = 1; i <= n; i++) right_b[i] = 1ll * i * b[i];
  for (int i = n; i >= 1; i--) left_a[i] = 1ll * (n + n - i + 1) * a[i];
  for (int i = n; i >= 1; i--) left_b[i] = 1ll * (n + n - i) * b[i];
  for (int i = n; i >= 1; i--)
    va[i] = a[i] + va[i + 1], right_a[i] += right_a[i + 1],
    left_a[i] += left_a[i + 1];
  for (int i = n; i >= 1; i--)
    vb[i] = b[i] + vb[i + 1], right_b[i] += right_b[i + 1],
    left_b[i] += left_b[i + 1];
  long long ans = 0, now = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2) {
      ans = max(ans, now + right_a[i] + va[i] * (i - 1) + left_b[i] +
                         vb[i] * (i - 1));
      long long cnt = 1ll * (i - 1) * 2;
      now += cnt * a[i] + (cnt + 1) * b[i];
    } else {
      ans = max(ans, now + left_a[i] + va[i] * (i - 2) + right_b[i] +
                         vb[i] * (i - 2));
      long long cnt = 1ll * (i - 1) * 2;
      now += (cnt + 1) * a[i] + (cnt)*b[i];
    }
  }
  printf("%lld\n", ans);
  return 0;
}
