#include <bits/stdc++.h>
using namespace std;
const int oo = 1e9;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> up(n), dw(n);
  for (int i = (0); i < (n); ++i) cin >> up[i];
  for (int i = (0); i < (n); ++i) cin >> dw[i];
  vector<long long> sum(n);
  for (int i = (0); i < (n); ++i) sum[i] = up[i] + dw[i];
  for (int i = (1); i < (n); ++i) sum[n - i - 1] += sum[n - i];
  vector<long long> a(n), b(n);
  for (int i = (0); i < (n); ++i) {
    a[0] += (i * up[i] + (2 * n - i - 1) * dw[i]);
    b[0] += (i * dw[i] + (2 * n - i - 1) * up[i]);
  }
  for (int i = (1); i < (n); ++i) {
    a[i] = a[i - 1] - (2 * (n - i) + 1) * dw[i - 1] - sum[i];
    b[i] = b[i - 1] - (2 * (n - i) + 1) * up[i - 1] - sum[i];
  }
  long long ans = 0, curr = 0;
  for (int i = (0); i < (n); ++i) {
    ans = max(ans, curr + (i % 2 ? b[i] : a[i]) + 2 * i * sum[i]);
    if (i % 2)
      curr += (2 * i) * dw[i] + (2 * i + 1) * up[i];
    else
      curr += (2 * i) * up[i] + (2 * i + 1) * dw[i];
  }
  ans = max(ans, curr);
  cout << ans << '\n';
  return 0;
}
