#include <bits/stdc++.h>
using namespace std;
const long long int maxn = 7 * 100000 + 50, inf = 1e13;
long long int a[maxn];
long long int b[maxn];
long long int a1[maxn], b1[maxn], a2[maxn], b2[maxn];
int main() {
  long long int res = -1;
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    if (i == 0) continue;
    a1[i] = a1[i - 1] + (a[i] * i);
    a2[i] = a2[i - 1] + (a[i]);
  }
  for (long long int i = 0; i < n; i++) {
    cin >> b[i];
  }
  if (n == 1) {
    cout << b[0];
    return 0;
  }
  if (n == 2) {
    cout << max(a[1] * 1 + b[1] * 2 + b[0] * 3, b[0] * 1 + b[1] * 2 + a[1] * 3);
    return 0;
  }
  reverse(a, a + n);
  b2[0] = b[0];
  for (long long int i = 0; i < n; i++) {
    if (i == 0) continue;
    b1[i] = b1[i - 1] + (b[i] * i);
    b2[i] = b2[i - 1] + (b[i]);
  }
  for (long long int i = 0; i < n; i++) {
    b1[i + n] = b1[n + i - 1] + (a[i] * (i + n));
    b2[i + n] = b2[n + i - 1] + (a[i]);
  }
  reverse(b, b + n);
  for (long long int i = 0; i < n; i++) {
    a1[i + n] = a1[n + i - 1] + (b[i] * (i + n));
    a2[i + n] = a2[n + i - 1] + (b[i]);
  }
  cout << endl;
  reverse(b, b + n);
  reverse(a, a + n);
  long long int o = 4, p = 0;
  res = max(res, a1[n + n - 1]);
  res = max(res, (b2[n + n - 2] + b1[n + n - 2]));
  p = 1 * b[0] + 2 * b[1] + 3 * a[1];
  for (long long int i = 2; i < n - 1; i++) {
    if (i % 2 == 0) {
      long long int x = a1[i - 1 + ((2 * n) - i * 2)] - a1[i - 1] +
                        (a2[i - 1 + ((2 * n) - i * 2)] - a2[i - 1]) * (o - i) +
                        p;
      res = max(res, x);
      p += o * a[i] + (o + 1) * b[i];
      o += 2;
    } else {
      long long int x = b1[i - 1 + ((2 * n) - i * 2)] - b1[i - 1] +
                        (b2[i - 1 + ((2 * n) - i * 2)] - b2[i - 1]) * (o - i) +
                        p;
      res = max(res, x);
      p += o * b[i] + (o + 1) * a[i];
      o += 2;
    }
  }
  if (n % 2 == 1)
    res = max(res, p + ((((n - 1) * 2)) * a[n - 1]) +
                       ((((n - 1) * 2) + 1) * b[n - 1]));
  else
    res = max(res, p + ((((n - 1) * 2)) * b[n - 1]) +
                       ((((n - 1) * 2) + 1) * a[n - 1]));
  cout << res;
  return 0;
}
