#include <bits/stdc++.h>
using namespace std;
int a[300005], b[300005];
long long sum[300005], tsum = 0, sum1 = 0, sum2 = 0, ans = 0;
int main(void) {
  int i, n;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (i = 1; i <= n; ++i) scanf("%d", &b[i]);
  for (i = n; i >= 1; --i) sum[i] = sum[i + 1] + a[i] + b[i];
  for (i = 1; i <= n; ++i)
    sum1 += 1LL * (i - 1) * a[i] + 1LL * (2 * n - i) * b[i];
  for (i = 1; i <= n; ++i)
    sum2 += 1LL * (i - 1) * b[i] + 1LL * (2 * n - i) * a[i];
  for (i = 1; i <= n; ++i) {
    if (i & 1) {
      ans = max(ans, tsum + sum1 + 1LL * (i - 1) * sum[i]);
      tsum += 1LL * (2 * i - 2) * a[i] + 1LL * (2 * i - 1) * b[i];
    } else {
      ans = max(ans, tsum + sum2 + 1LL * (i - 1) * sum[i]);
      tsum += 1LL * (2 * i - 2) * b[i] + 1LL * (2 * i - 1) * a[i];
    }
    sum1 -= 1LL * (i - 1) * a[i] + 1LL * (2 * n - i) * b[i];
    sum2 -= 1LL * (i - 1) * b[i] + 1LL * (2 * n - i) * a[i];
  }
  printf("%lld\n", ans);
  return 0;
}
