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;
namespace fastIO {
bool IOerror = 0;
inline char nc() {
  static char buf[100000], *p1 = buf + 100000, *pend = buf + 100000;
  if (p1 == pend) {
    p1 = buf;
    pend = buf + fread(buf, 1, 100000, stdin);
    if (pend == p1) {
      IOerror = 1;
      return -1;
    }
  }
  return *p1++;
}
inline bool blank(char ch) {
  return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
}
inline void read(int &x) {
  char ch;
  while (blank(ch = nc()))
    ;
  if (IOerror) return;
  for (x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0')
    ;
}
};  // namespace fastIO
using namespace fastIO;
int a[2][1100000];
long long sum[2][1100000], fsum[2][1100000], esum[2][1100000];
int main() {
  int n;
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(a[0][i]);
    sum[0][i] += sum[0][i - 1] + a[0][i];
  }
  for (int i = 1; i <= n; ++i) {
    read(a[1][i]);
    sum[1][i] += sum[1][i - 1] + a[1][i];
  }
  for (int i = n; i >= 1; --i) {
    fsum[0][n - i + 1] += fsum[0][n - i] + (n - i) * a[0][n - i + 1];
    fsum[1][n - i + 1] += fsum[1][n - i] + (n - i) * a[1][n - i + 1];
    esum[0][i] += esum[0][i + 1] + (n - i) * a[0][i];
    esum[1][i] += esum[1][i + 1] + (n - i) * a[1][i];
  }
  long long res = 0, ans = 0;
  int t = 0, j = 0, times = 0;
  for (int i = 1; i < n; ++i) {
    long long temp = res;
    temp += (fsum[t][n] - fsum[t][i]) + (j - i + 1) * (sum[t][n] - sum[t][i]);
    temp += (esum[t ^ 1][i] - esum[t ^ 1][n + 1]) +
            (n - i + times + 1) * (sum[t ^ 1][n] - sum[t ^ 1][i - 1]);
    ans = max(ans, temp);
    t ^= 1;
    res += (times + 1) * a[t][i] + (times + 2) * a[t][i + 1];
    times += 2;
    j += 2;
  }
  if (n & 1)
    res += (times + 1) * a[1][n];
  else
    res += (times + 1) * a[0][n];
  ans = max(ans, res);
  printf("%lld\n", ans);
  return 0;
}
