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 int N = 3e5 + 1;
const int MOD = 1e9 + 7;
const int base = 257;
const int M = 1e6 + 1;
const int INFI = 1e8;
long long Hash[M], po[M];
long long gethash(long long l, long long r) {
  return ((Hash[r] - Hash[l - 1] * po[r - l + 1] + MOD * MOD) % MOD);
}
void precomputehashing() {
  po[0] = 1;
  for (int i = 1; i <= M; i++) po[i] = (po[i - 1] * base) % MOD;
  string s;
  s = " " + s;
  for (int i = 1; i <= s.size() - 1; i++)
    Hash[i] = (Hash[i - 1] * base + s[i] - '*' + 1) % MOD;
}
long long fac[N], ifac[N];
long long PowerMod(long long a, long long n) {
  long long ret = 1;
  while (n) {
    if (n & 1) {
      ret *= a;
      ret %= MOD;
    }
    a *= a;
    a %= MOD;
    n /= 2;
  }
  return ret;
}
void precomputecombinatoris() {
  int i;
  fac[0] = 1;
  for (i = 1; i < N; i++) {
    fac[i] = (i * fac[i - 1]) % MOD;
  }
  ifac[N - 1] = PowerMod(fac[N - 1], MOD - 2);
  for (i = N - 2; i >= 0; i--) {
    ifac[i] = ((i + 1) * ifac[i + 1]) % MOD;
  }
}
long long C(int r, int n) {
  long long ret = fac[n];
  ret *= ifac[r];
  ret %= MOD;
  ret *= ifac[n - r];
  ret %= MOD;
  return ret;
}
long long dp[N][5], a[N], b[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  for (int i = 1; i <= n; i++) {
    dp[i][3] = dp[i - 1][3] + a[i] + b[i];
  }
  for (int i = 1; i <= n; i++) {
    dp[i][0] = dp[i - 1][0] + a[i] * (i - 1) + b[i] * (2 * n - i);
    dp[i][1] = dp[i - 1][1] + b[i] * (i - 1) + a[i] * (2 * n - i);
  }
  for (int i = 1; i <= n; i++) {
    if (i & 1) {
      dp[i][2] = dp[i - 1][2] + a[i] * (2 * i - 2) + b[i] * (2 * i - 1);
    } else {
      dp[i][2] = dp[i - 1][2] + b[i] * (2 * i - 2) + a[i] * (2 * i - 1);
    }
  }
  long long res = max(dp[n][0], dp[n][2]);
  for (int i = 1; i <= n - 1; i++) {
    if (i & 1) {
      res =
          max(res, dp[i][2] + dp[n][1] - dp[i][1] + (dp[n][3] - dp[i][3]) * i);
    } else {
      res =
          max(res, dp[i][2] + dp[n][0] - dp[i][0] + (dp[n][3] - dp[i][3]) * i);
    }
  }
  cout << res;
  return 0;
}
