#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int N = 1e6 + 1;
const int M = 2;
long long dp[N];
long long second[N];
int val[M][N];
long long GR[N], GR1[N];
int n;
long long find_max(int col) {
  if (n - 1 - col == 0) {
    return val[1][col];
  }
  if (n - 1 - col == 1) {
    return max(val[0][col + 1] + val[1][col + 1] * 2 + val[1][col] * 3,
               val[1][col] + val[1][col + 1] * 2 + val[0][col + 1] * 3);
  }
  if (dp[col] != -1) return dp[col];
  long long& ret = dp[col];
  ret = 0;
  int tol = n * 2 - col * 2;
  ret = GR1[col + 1] + val[1][col] * 1ll * (tol - 1) + second[col + 1];
  long long r1 = 4 * second[col + 2] + find_max(col + 2) + val[1][col] +
                 val[1][col + 1] * 2 + val[0][col + 1] * 3;
  long long r2 = val[1][col] + GR[col + 1] + 2 * second[col + 1];
  r1 = max(r1, r2);
  ret = max(r1, ret);
  return ret;
}
int main() {
  cin >> n;
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < n; j++) {
      cin >> val[i][j];
    }
  }
  second[n - 1] = val[0][n - 1] + val[1][n - 1];
  for (int i = n - 2; i >= 0; i--) {
    second[i] = second[i + 1] + val[0][i] + val[1][i];
  }
  GR[n] = 0;
  GR1[n] = 0;
  int col = 0;
  for (int i = n - 1; i >= 0; i--) {
    col += 2;
    GR1[i] = GR1[i + 1] + second[i + 1] + (col - 1) * 1ll * val[1][i];
    GR[i] = GR[i + 1] + second[i + 1] + (col - 1) * 1ll * val[0][i];
  }
  cout << find_max(0) << endl;
  return 0;
}
