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;
int a[2][1000009];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < n; ++j) scanf("%d", &a[i][j]);
  long long int left = 0, down = 0, zig = 0;
  for (int i = 0; i < n; ++i) {
    left += i * a[0][i] + (2 * n - i - 1) * a[1][i];
  }
  down = a[1][n - 1];
  for (int i = 1; i < n; ++i) {
    down += (i + 1) * a[1][i] + (2 * n - i) * a[0][i];
  }
  int k = 0;
  for (int i = 0; i < 2 * n; ++i) {
    zig += i * a[k][i % n];
    k = 1 - k;
  }
  printf("%lld\n", max(left, max(down, zig)));
  return 0;
}
