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;
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;
}
