#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  vector<long long int> sa(n), sb(n), ta(n), tb(n);
  sb[n - 1] = b[n - 1];
  sa[n - 1] = sb[n - 1] + a[n - 1];
  ta[n - 1] = b[n - 1];
  tb[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    sb[i] = sa[i + 1] + b[i];
    sa[i] = sb[i] + a[i];
    ta[i] = ta[i + 1] + sa[i + 1] + (2 * (n - i) - 1) * b[i];
    tb[i] = tb[i + 1] + sb[i + 1] + (2 * (n - i - 1)) * a[i + 1];
  }
  long long int counter = 0, curr = 0;
  long long max = (ta[0] > tb[0] + sb[0]) ? ta[0] : tb[0] + sb[0];
  for (int i = 0; i < n; i += 2) {
    if (ta[i] + curr + counter * sa[i] > max)
      max = ta[i] + curr + counter * sa[i];
    curr += a[i] * counter;
    counter++;
    if (tb[i] + curr + counter * sb[i] > max)
      max = tb[i] + curr + counter * sb[i];
    curr += b[i] * counter;
    counter++;
    if (i < n - 1) {
      curr += b[i + 1] * counter + a[i + 1] * (counter + 1);
      counter += 2;
    }
  }
  cout << max;
  return 0;
}
