#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 100;
long long sum[2][N], sum_rev[2][N], p_sum[2][N];
signed main() {
  long long n;
  cin >> n;
  long long a[2][n];
  for (long long i = 0; i < 2; i++)
    for (long long j = 0; j < n; j++) cin >> a[i][j];
  for (long long i = 0; i < 2; i++)
    for (long long j = n - 1; j >= 0; j--) {
      sum[i][j] = sum[i][j + 1] + j * a[i][j];
      sum_rev[i][j] = sum_rev[i][j + 1] + (n - j - 1) * a[i][j];
      p_sum[i][j] = p_sum[i][j + 1] + a[i][j];
    }
  long long ans = 0;
  long long s = 0;
  for (long long i = 0, j = 0; j < n; i ^= 1, j++) {
    long long new_ans = s;
    new_ans += sum[i][j] + j * p_sum[i][j];
    new_ans += sum_rev[i ^ 1][j] + (n + j) * p_sum[i ^ 1][j];
    ans = max(ans, new_ans);
    s += (j * 2) * a[i][j];
    s += (j * 2 + 1) * a[i ^ 1][j];
  }
  cout << ans;
}
