#include <bits/stdc++.h>
using namespace std;
long long a[500010], b[500010], n;
int main() {
  cin >> n;
  long long sum = 0, qsum = 0, nsum = 0, rsum = 0, nb = 0, ans = 0;
  for (int i = 0; i < n; i++) scanf("%I64d", &a[i]);
  for (int i = 0; i < n; i++) scanf("%I64d", &b[i]);
  for (int i = 0; i < n; i++) {
    sum += (a[i] + b[i]);
  }
  for (int i = 0; i < n; i++) {
    qsum += (a[i] * i + b[i] * (2 * n - i - 1));
  }
  nsum = sum;
  rsum = qsum;
  for (int i = 0; i < n; i += 2) {
    ans = max(ans, rsum + nb);
    nb += (a[i] * (i * 2) + a[i + 1] * (i * 2 + 3) + b[i] * (i * 2 + 1) +
           b[i + 1] * (i * 2 + 2));
    nsum -= (a[i] + a[i + 1] + b[i] + b[i + 1]);
    rsum -= (a[i] * (i * 2) + a[i + 1] * (i * 2 + 1) + b[i] * (2 * n - 1) +
             b[i + 1] * (2 * n - 2));
    rsum += nsum * 2;
  }
  ans = max(ans, rsum + nb);
  sum = 0;
  qsum = 0;
  for (int i = 1; i < n; i++) {
    sum += (a[i] + b[i]);
  }
  for (int i = 1; i < n; i++) {
    qsum += (a[i] * (2 * n - i) + b[i] * (i + 1));
  }
  nsum = sum;
  rsum = qsum;
  nb = b[0];
  for (int i = 1; i < n; i += 2) {
    ans = max(ans, rsum + nb);
    nb += (a[i] * (i * 2 + 1) + a[i + 1] * (i * 2 + 2) + b[i] * (i * 2) +
           b[i + 1] * (i * 2 + 3));
    nsum -= (a[i] + a[i + 1] + b[i] + b[i + 1]);
    rsum -= (a[i] * (2 * n - 1) + a[i + 1] * (2 * n - 2) + b[i] * (i * 2) +
             b[i + 1] * (i * 2 + 1));
    rsum += nsum * 2;
  }
  ans = max(ans, rsum + nb);
  cout << ans << endl;
}
