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;
const int maxn = 1e6 + 5, dirx[4] = {1, 0, -1, 0}, diry[4] = {0, 1, 0, 1};
long long n, a[3][maxn], dp1[3][maxn], dp2[3][maxn], sa[maxn];
int main(void) {
  scanf("%lld", &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]);
  memset(dp1, 0, sizeof(dp1));
  memset(dp2, 0, sizeof(dp2));
  sa[n] = a[1][n] + a[2][n];
  for (int i = n - 1; i >= 1; i--) sa[i] = sa[i + 1] + a[1][i] + a[2][i];
  dp1[1][1] = 0;
  for (int i = 1, x = 1, y = 1, cir = 0; i <= 2 * n; i++, cir++) {
    int pre = dp1[x][y];
    x += dirx[cir % 4], y += diry[cir % 4];
    dp1[x][y] = pre + a[x][y] * i;
  }
  dp2[1][n] = a[2][n];
  dp2[2][n] = a[1][n];
  for (int i = n - 1; i >= 1; i--) {
    dp2[1][i] = dp2[1][i + 1] + sa[i + 1] + a[2][i] * ((n - i + 1) * 2 - 1);
    dp2[2][i] = dp2[2][i + 1] + sa[i + 1] + a[1][i] * ((n - i + 1) * 2 - 1);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2)
      ans = max(ans, dp1[1][i - 1] + dp2[1][i] + sa[i] * 2 * (i - 1));
    else
      ans = max(ans, dp1[2][i - 1] + dp2[2][i] + sa[i] * 2 * (i - 1));
  }
  printf("%lld", ans);
  return 0;
}
