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;
const int MAXN = 1e6;
inline int read() {
  char c = getchar();
  int x = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
int N;
long long a[MAXN], b[MAXN];
long long Get(int opt) {
  long long ans = 0, cur = -1;
  if (opt == 1) {
    for (int i = 1; i <= N; i++) ans += a[i] * (++cur);
    for (int i = N; i >= 1; i--) ans += b[i] * (++cur);
  } else if (opt == 2) {
    for (int i = 1; i <= N; i++) ans += b[i] * (++cur);
    for (int i = N; i >= 2; i--) ans += a[i] * (++cur);
  } else if (opt == 3) {
    cur = 0;
    for (int i = 1; i <= N; i++) {
      if (i & 1)
        ans = ans + a[i] * cur + b[i] * (cur + 1);
      else
        ans = ans + b[i] * cur + a[i] * (cur + 1);
      cur += 2;
    }
  }
  return ans;
}
int main() {
  N = read();
  for (int i = 1; i <= N; i++) a[i] = read();
  for (int i = 1; i <= N; i++) b[i] = read();
  printf("%lld\n", max(Get(1), max(Get(2), Get(3))));
  puts("");
  return 0;
}
