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 sum[300010], num[2][300010], SUMM[2][300010], ans;
int n;
inline int read() {
  int e = 0, ch = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') ch = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    e = e * 10 + c - '0';
    c = getchar();
  }
  return e * ch;
}
int main() {
  n = read();
  for (int j = 0; j < n; j++) num[0][j] = read();
  for (int j = 0; j < n; j++) num[1][j] = read();
  for (int i = n - 1; i >= 0; i--) sum[i] = sum[i + 1] + num[0][i] + num[1][i];
  for (int i = n - 1; i >= 0; i--)
    for (int l = 0; l <= 1; l++)
      SUMM[l][i] =
          SUMM[l][i + 1] + sum[i + 1] + ((n - i) * 2 - 1) * num[1 - l & 1][i];
  int ti = 0;
  long long sss = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, SUMM[i & 1][i] + sum[i] * i * 2 + sss);
    sss += ti * num[i & 1][i] + (ti + 1) * num[(i + 1) & 1][i];
    ti += 2;
  }
  cout << ans;
}
