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 read() {
  long long res = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (isdigit(ch)) res = res * 10 + ch - 48, ch = getchar();
  return res * flag;
}
void print(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 + 48);
}
const long long N = 3000000 + 5;
long long n, ans = 0;
long long a[N], b[N], s[6][N];
signed main() {
  n = read();
  for (long long i = (1); i <= (n); ++i) a[i] = read();
  for (long long i = (1); i <= (n); ++i) b[i] = read();
  for (long long i = (1); i <= (n); ++i)
    s[0][i] = s[0][i - 1] + a[i], s[1][i] = s[1][i - 1] + b[i],
    s[2][i] = s[2][i - 1] + a[i] * i, s[3][i] = s[3][i - 1] + b[i] * i;
  for (long long i = (n); i >= (1); --i)
    s[4][i] = s[4][i + 1] + a[i] * (n - i + 1),
    s[5][i] = s[5][i + 1] + b[i] * (n - i + 1);
  ans = s[1][n] * n + s[2][n] + s[5][1];
  bool state = false;
  long long now = 0;
  for (long long i = (1); i <= (n); ++i) {
    if (!state)
      now += ((i << 1) - 1) * a[i] + (i << 1) * b[i];
    else
      now += ((i << 1) - 1) * b[i] + (i << 1) * a[i];
    state = !state;
    long long tmp = now;
    if (!state)
      tmp += s[2][n] - s[2][i] + (s[0][n] - s[0][i]) * i + s[5][i + 1] -
             s[5][n + 1] + (s[1][n] - s[1][i]) * (n + i);
    else
      tmp += s[3][n] - s[3][i] + (s[1][n] - s[1][i]) * i + s[4][i + 1] -
             s[4][n + 1] + (s[0][n] - s[0][i]) * (n + i);
    ans = std::max(ans, tmp);
  }
  for (long long i = (1); i <= (n); ++i) ans -= a[i] + b[i];
  print(ans), puts("");
}
