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;
int n, A[2][300005];
int main() {
  scanf("%d", &n);
  int i;
  for (i = 1; i <= n; i++) scanf("%d", &A[0][i]);
  for (i = 1; i <= n; i++) scanf("%d", &A[1][i]);
  int ans = 0, ans1;
  for (i = 1; i <= n; i++) ans += A[0][i] * (i - 1);
  for (i = n; i; --i) ans += A[1][i] * (n + n - i);
  ans1 = ans;
  ans = 0;
  for (i = 1; i <= n; i++) {
    ans += A[1][i] * i;
  }
  for (i = n; i > 1; --i) {
    ans += A[0][i] * (n + 1 + n - i);
  }
  ans1 = max(ans1, ans);
  ans = 0;
  for (i = 1; i <= n; i++) {
    ans += A[0][i] * (2 * (i - 1)) + A[1][i] * (2 * (i - 1) + 1);
  }
  ans1 = max(ans, ans1);
  printf("%d", ans1);
  return 0;
}
