#include <bits/stdc++.h>
const int N = 600100;
using namespace std;
int a[N];
long long sum1[N];
long long sum2[N];
long long pre_sum1[N];
long long pre_sum2[N];
long long inc_sum1[N];
long long inc_sum2[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> a[2 * n - i];
  for (int i = 1; i <= n + n; i++) pre_sum1[i] = pre_sum1[i - 1] + a[i];
  for (int i = 1; i <= n + n; i++)
    pre_sum2[i] = pre_sum2[i - 1] + a[2 * n - i + 1];
  for (int i = 1; i <= n + n; i++) sum1[i] = 1ll * i * a[i];
  for (int i = 1; i <= n + n; i++) sum2[i] = 1ll * i * a[2 * n - i + 1];
  for (int i = 1; i <= n + n; i++) inc_sum1[i] = inc_sum1[i - 1] + sum1[i];
  for (int i = 1; i <= n + n; i++) inc_sum2[i] = inc_sum2[i - 1] + sum2[i];
  long long res = 0;
  for (int i = 1; i <= n + n; i++) res += 1ll * (i - 1) * a[i];
  long long alt = 0;
  for (int i1 = 1, i2 = 2 * n, timer = 0; i1 <= n; i1++, i2--, timer++) {
    if (i1 & 1) {
      alt += 1ll * timer * a[i1];
      timer++;
      alt += 1ll * timer * a[i2];
    } else {
      alt += 1ll * timer * a[i2];
      timer++;
      alt += 1ll * timer * a[i1];
    }
    long long curr_res = alt;
    if (i1 + 1 == i2) {
      res = max(res, curr_res);
      continue;
    }
    if (!(i1 & 1))
      curr_res += 1ll * (timer - i1) * (pre_sum1[i2 - 1] - pre_sum1[i1]) +
                  (inc_sum1[i2 - 1] - inc_sum1[i1]);
    else
      curr_res += 1ll * (timer - i1) * (pre_sum2[i2 - 1] - pre_sum2[i1]) +
                  (inc_sum2[i2 - 1] - inc_sum2[i1]);
    res = max(res, curr_res);
  }
  cout << res << '\n';
  return 0;
}
