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