6
12 8 12 17 20 5
17 4 8 8 8 4
 6
4 1 12 9 3 11
12 20 19 12 19 11
 1
1
1
 2
1 2
1 1
 1
7
5
 6
16 20 18 7 14 2
17 12 4 10 7 4

705
 917
 1
 9
 5
 741

#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];
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 += 2 * second[col + 2] + val[1][col] * 1ll * (tol - 1) +
         val[1][col + 1] * 1ll * (tol - 2) + val[0][col + 1] +
         find_max(col + 2);
  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 = 3 * second[col + 2] + val[1][col] + val[1][col + 1] * 2 +
                 (tol - 1) * 1ll * val[0][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];
  }
  cout << find_max(0) << endl;
  return 0;
}
