#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);
}
