#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 100;
long long ar[N], ap[N], n;
long long cos1[N], cos2[N];
long long vis1[N];
long long sum1[N], sum2[N], su1[N], su2[N];
void pre() {
  for (int i = 1; i <= n; i++) vis1[i] = (i - 1) * ar[i];
  for (int i = n; i >= 1; i--)
    sum1[i] = sum1[i + 1] + vis1[i], su1[i] = su1[i + 1] + ar[i];
  for (int i = n; i >= 1; i--)
    sum2[i] = (n + n - i) * ap[i] + sum2[i + 1], su2[i] = su2[i + 1] + ap[i];
  for (int i = 1; i <= n; i++)
    if (i % 2) cos1[i] = sum1[i] + sum2[i] + (su1[i] + su2[i]) * (i - 1);
  memset(sum1, 0, sizeof sum1);
  memset(sum2, 0, sizeof sum2);
  for (int i = 2; i <= n; i++) vis1[i] = i * ap[i];
  for (int i = n; i >= 2; i--)
    sum1[i] = sum1[i + 1] + vis1[i], su1[i] = su1[i + 1] + ap[i];
  for (int i = n; i >= 1; i--)
    sum2[i] = (n + 1 + n - i) * ar[i] + sum2[i + 1],
    su2[i] = su2[i + 1] + ar[i];
  for (int i = 1; i <= n; i++)
    if (i % 2 == 0) cos2[i] = (su1[i] + su2[i]) * (i - 2) + sum1[i] + sum2[i];
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> ar[i];
  for (int i = 1; i <= n; i++) cin >> ap[i];
  pre();
  long long mx = 0;
  long long cnt = 0, s = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2) {
      mx = max(mx, s + cos1[i]);
      s += ar[i] * cnt++;
      s += ap[i] * cnt++;
    } else {
      mx = max(mx, s + cos2[i]);
      s += ap[i] * cnt++;
      s += ar[i] * cnt++;
    }
    mx = max(mx, s);
  }
  cout << mx << endl;
  return 0;
}
