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() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  int n;
  cin >> n;
  vector<long long> a(n), b(n), r(n, 0);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  r[n - 1] = a[n - 1] + b[n - 1];
  for (int i = n - 2; i >= 0; i--) r[i] = r[i + 1] + a[i] + b[i];
  vector<vector<long long> > lap(n, vector<long long>(2, 0));
  lap[n - 1][0] = b[n - 1];
  lap[n - 1][1] = a[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    lap[i][0] = r[i + 1] + lap[i + 1][0] + b[i] * (2 * (n - i) - 1);
    lap[i][1] = r[i + 1] + lap[i + 1][1] + a[i] * (2 * (n - i) - 1);
  }
  vector<vector<long long> > dp(n, vector<long long>(2, 0));
  dp[n - 1][0] = b[n - 1];
  dp[n - 1][1] = a[n - 1];
  for (int c = n - 2; c >= 0; c--) {
    dp[c][0] = lap[c][0];
    dp[c][1] = lap[c][1];
    dp[c][0] = max(dp[c][0], b[c] + 2 * r[c + 1] + dp[c + 1][1]);
    dp[c][1] = max(dp[c][1], a[c] + 2 * r[c + 1] + dp[c + 1][0]);
  }
  cout << dp[0][0] << endl;
  return 0;
}
