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 a[2][300009];
long long sum123[2][300009];
long long sum321[2][300009];
long long sum111[2][300009];
int main() {
  long long n;
  scanf("%lld", &n);
  for (long long i = 0; i < 2; i++)
    for (long long j = 0; j < n; j++) scanf("%lld", &a[i][j]);
  for (long long i = 0; i < 2; i++) {
    for (long long j = n - 1; j >= 0; j--) {
      sum123[i][j] = sum123[i][j + 1] + a[i][j] * (j + 1);
      sum321[i][j] = sum321[i][j + 1] + a[i][j] * (n - j);
      sum111[i][j] = sum111[i][j + 1] + a[i][j];
    }
  }
  long long res = 0, zig = 0, ans = 0, i = 0;
  for (long long j = 0; j < n; j++) {
    res = 0;
    res += zig;
    res += sum123[i][j] + sum111[i][j] * (j);
    res += sum321[i ^ 1][j] + sum111[i ^ 1][j] * (n + j);
    ans = max(ans, res);
    zig += a[i][j] * (2 * j + 1) + a[i ^ 1][j] * (2 * j + 2);
    i = i ^ 1;
  }
  for (long long j = 0; j < n; j++) ans = ans - (a[0][j] + a[1][j]);
  printf("%lld", ans);
}
