#include <bits/stdc++.h>
using namespace std;
long long a[4][300100];
long long rec[4][300100];
long long sum[300100];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[1][i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[2][i]);
  }
  sum[n + 1] = 0;
  for (int i = n; i >= 1; i--) {
    sum[i] = sum[i + 1] + a[1][i] + a[2][i];
  }
  for (int i = n; i >= 1; i--) {
    rec[2][i] =
        rec[2][i + 1] + sum[i + 1] + a[2][i] + a[1][i] * (n - i + 1) * 2ll;
    rec[1][i] =
        rec[1][i + 1] + sum[i + 1] + a[1][i] + a[2][i] * (n - i + 1) * 2ll;
  }
  int step = 0;
  long long res = 0, maxn = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2 == 1) {
      long long curans = res + rec[1][i] + (step - 1) * sum[i];
      if (curans > maxn) maxn = curans;
      res += 1ll * step * a[1][i];
      step++;
      res += 1ll * step * a[2][i];
      step++;
    } else {
      long long curans = res + rec[2][i] + (step - 1) * sum[i];
      if (curans > maxn) maxn = curans;
      res += 1ll * step * a[2][i];
      step++;
      res += 1ll * step * a[1][i];
      step++;
    }
  }
  maxn = max(maxn, res);
  printf("%lld\n", maxn);
  return 0;
}
