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