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>
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++) {
    alt += 1ll * timer * a[i1];
    timer++;
    alt += 1ll * timer * a[i2];
    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;
}
