#include <bits/stdc++.h>
using namespace std;
long long int exp(long long int a, long long int b, long long int m);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  long long int b[n];
  for (long long int i = 0; i < n; i++) cin >> b[i];
  long long int ps[n + 1][2];
  long long int ps1[n + 1][2];
  long long int s = 0;
  long long int s2 = 0;
  for (long long int i = 0; i < n; i++) {
    s += a[i];
    ps[i + 1][0] = s;
    s2 += (i + 1) * a[i];
    ps1[i + 1][0] = s2;
  }
  for (long long int i = n - 1; i >= 0; i--) {
    s += b[i];
    s2 += (n + n - 1 - i + 1) * b[i];
    ps[i + 1][1] = s;
    ps1[i + 1][1] = s2;
  }
  long long int second[n + 1][2];
  long long int ss1[n + 1][2];
  s = 0;
  s2 = 0;
  for (long long int i = 0; i < n; i++) {
    s += b[i];
    second[i + 1][1] = s;
    s2 += (i + 1) * b[i];
    ss1[i + 1][1] = s2;
  }
  for (long long int i = n - 1; i >= 0; i--) {
    s += a[i];
    s2 += (n + n - 1 - i + 1) * a[i];
    second[i + 1][0] = s;
    ss1[i + 1][0] = s2;
  }
  ps[0][0] = 0;
  ps[0][1] = 0;
  second[0][0] = 0;
  second[0][1] = 0;
  ps1[0][0] = 0;
  ps1[0][1] = 0;
  ss1[0][0] = 0;
  ss1[0][1] = 0;
  long long int t = 0;
  long long int ansf = 0, ansc = 0, ansp = 0;
  for (long long int i = 0; i < n; i++) {
    if (t % 4 == 0) {
      ansc =
          ps1[i + 1][1] - ps1[i][0] + (ps[i + 1][1] - ps[i][0]) * (t - (i + 1));
      ansf = max(ansf, ansc + ansp);
      ansp += a[i] * t;
      t++;
      ansp += b[i] * t;
      t++;
    } else {
      ansc = ss1[i + 1][0] - ss1[i][1] +
             (second[i + 1][0] - second[i][1]) * (t - (i + 1));
      ansf = max(ansf, ansc + ansp);
      ansp += b[i] * t;
      t++;
      ansp += a[i] * t;
      t++;
    }
  }
  ansf = max(ansf, ansp);
  cout << ansf << endl;
  return 0;
}
long long int exp(long long int a, long long int b, long long int m) {
  if (b == 0) {
    return 1;
  }
  long long int temp = exp(a, b / 2, m);
  temp = (temp * temp) % m;
  if (b & 1) {
    return (temp * (a % m)) % m;
  }
  return temp;
}
