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 long long maxn = 3e5 + 5;
long long a[4][maxn];
int main() {
  long long n;
  scanf("%lld", &n);
  for (long long i = 0; i < n; i++) scanf("%lld", &a[0][i]);
  for (long long i = 0; i < n; i++) scanf("%lld", &a[1][i]);
  long long tmp1 = 0, cnt = 0;
  for (long long i = 0; i < n; i++, cnt++) tmp1 += cnt * a[0][i];
  tmp1 += n * a[1][n - 1];
  cnt++;
  for (long long i = n - 2; i >= 0; i--, cnt++) tmp1 += cnt * a[1][i];
  ;
  long long tmp2 = 0;
  cnt = 1;
  for (long long i = 1; i < n; i++, cnt++) tmp2 += cnt * a[1][i];
  for (long long i = n - 1; i >= 1; i--, cnt++) tmp2 += cnt * a[0][i];
  long long tmp3 = 0;
  cnt = 2;
  tmp3 += a[1][0];
  bool f = 1;
  for (long long i = 1; i < n; i++, cnt++) {
    if (f) {
      tmp3 += cnt * a[1][i];
      cnt++;
      tmp3 += cnt * a[0][i];
      f = 0;
    } else {
      tmp3 += cnt * a[0][i];
      cnt++;
      tmp3 += cnt * a[1][i];
      f = 1;
    }
  }
  long long ans = max(max(tmp1, tmp2), tmp3);
  printf("%lld\n", ans);
}
