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>
long long t, m, p, ans, a, i, j, o, x[3][300005];
long long s[3][300005], frosum[3][300005], backsum[3][300005];
int main() {
  scanf("%lld", &a);
  for (i = 0; i < 2; i++) {
    for (j = 1; j <= a; j++) scanf("%lld", &x[i][j]);
  }
  for (i = 0; i < 2; i++) {
    for (j = a; j >= 1; j--) {
      s[i][j] = s[i][j + 1] + x[i][j];
    }
  }
  for (i = 0; i < 2; i++) {
    for (j = a - 1; j >= 1; j--) {
      backsum[i][j] = backsum[i][j + 1] + (a - j) * x[i][j];
      frosum[i][j] = frosum[i][j + 1] + s[i][j + 1];
    }
  }
  i = 0;
  p = 0;
  t = 0;
  j = 1;
  while (1) {
    m = p + frosum[i][j] + backsum[1 - i][j] + s[i][j] * t +
        s[1 - i][j] * (t + a - j + 1);
    ans = std::max(ans, m);
    if (j == a) {
      break;
    }
    p += x[i][j] * t;
    t++;
    i = 1 - i;
    p += x[i][j] * t;
    t++;
    j++;
  }
  printf("%lld", ans);
}
