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;
int main() {
  unsigned long int n, sum;
  cin >> n;
  vector<vector<unsigned long int> > forest(2), dp(2);
  forest[0].resize(n);
  forest[1].resize(n);
  dp[0].resize(n);
  dp[1].resize(n);
  for (int i = 0; i < n; i++) cin >> forest[0][i];
  for (int j = 0; j < n; j++) cin >> forest[1][j];
  dp[0][n - 1] = forest[1][n - 1];
  dp[1][n - 1] = forest[0][n - 1];
  sum = forest[1][n - 1] + forest[0][n - 1];
  for (int i = n - 2; i >= 0; i--) {
    dp[0][i] = dp[0][i + 1] + sum + (1 + 2 * (n - i - 1)) * forest[1][i];
    dp[0][i] = max(dp[0][i], forest[1][i] + dp[1][i + 1] + 2 * sum);
    dp[1][i] = dp[1][i + 1] + sum + (1 + 2 * (n - i - 1)) * forest[0][i];
    dp[1][i] = max(dp[1][i], forest[0][i] + dp[0][i + 1] + 2 * sum);
    sum += forest[0][i] + forest[1][i];
  }
  cout << dp[0][0] << endl;
  return 0;
}
