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(0);
  cin.tie();
  cout.tie();
  int n;
  cin >> n;
  long long dp[n][2];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      cin >> dp[j][i];
    }
  }
  vector<long long> x(n);
  vector<long long> topk(n), botk(n);
  x[n - 1] = dp[n - 1][0] + dp[n - 1][1];
  topk[n - 1] = dp[n - 1][1];
  botk[n - 1] = dp[n - 1][0];
  for (int i = n - 2; i >= 0; i--) {
    x[i] = x[i + 1] + dp[i][0] + dp[i][1];
    topk[i] = topk[i + 1] + x[i + 1] + dp[i][1] * ((n - i) * 2 - 1);
    botk[i] = botk[i + 1] + x[i + 1] + dp[i][0] * ((n - i) * 2 - 1);
  }
  long long ans[n];
  long long lastans[n];
  long long p = topk[0];
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      lastans[i] = (i ? lastans[i - 1] : 0) + (dp[i][0] * 2 * i) +
                   (dp[i][1] * (2 * i + 1));
      ans[i] = lastans[i] +
               (i != n - 1 ? botk[i + 1] + x[i + 1] * ((i + 1) * 2) : 0);
    } else {
      lastans[i] = (i ? lastans[i - 1] : 0) + (dp[i][1] * 2 * i) +
                   (dp[i][0] * (2 * i + 1));
      ans[i] = lastans[i] +
               (i != n - 1 ? topk[i + 1] + x[i + 1] * ((i + 1) * 2) : 0);
    }
    p = max(p, ans[i]);
  }
  cout << p;
}
