#include <bits/stdc++.h>
using namespace std;
long long a[2][300005], sum123[2][300005], sum321[2][300005], sum111[2][300005],
    n;
void solve() {
  cin >> n;
  long long i, j, sum = 0, ans = 0;
  for (i = 0; i < 2; i++)
    for (j = 0; j < n; j++) cin >> a[i][j];
  for (i = 0; i < 2; i++)
    for (j = n - 1; j >= 0; j--) {
      sum123[i][j] = sum123[i][j + 1] + (j + 1) * a[i][j];
      sum321[i][j] = sum321[i][j + 1] + (n - j) * a[i][j];
      sum111[i][j] = sum111[i][j + 1] + a[i][j];
    }
  for (i = 0, j = 0; j < n; j++, i = 1 - i) {
    long long val = sum;
    val += sum123[i][j] + j * sum111[i][j];
    val += sum321[1 - i][j] + (j + n) * sum111[1 - i][j];
    ans = max(ans, val);
    sum += (j + j + 1) * a[i][j];
    sum += (j + j + 2) * a[1 - i][j];
  }
  for (i = 0; i < n; i++) ans -= (a[0][i] + a[1][i]);
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
