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() {
  int n;
  cin >> n;
  vector<vector<long>> forest(2);
  forest[0].resize(n + 1);
  forest[1].resize(n + 1);
  vector<long long> travel1(2 * n + 1);
  vector<long long> travel2(2 * n + 1);
  vector<long long> storage1(2 * n + 1);
  vector<long long> storage2(2 * n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> forest[0][i];
    storage1[i] = forest[0][i];
    storage2[2 * n + 1 - i] = forest[0][i];
    travel1[i] = forest[0][i] * (i - 1);
    travel2[2 * n + 1 - i] = forest[0][i] * (2 * n - i);
  }
  for (int i = 1; i <= n; i++) {
    cin >> forest[1][i];
    storage1[2 * n + 1 - i] = forest[1][i];
    storage2[i] = forest[1][i];
    travel1[2 * n + 1 - i] = forest[1][i] * (2 * n - i);
    travel2[i] = forest[1][i] * (i - 1);
  }
  for (int i = 1; i <= 2 * n; i++) {
    storage1[i] += storage1[i - 1];
    storage2[i] += storage2[i - 1];
    travel1[i] += travel1[i - 1];
    travel2[i] += travel2[i - 1];
  }
  long long max = 0;
  long long process = 0;
  for (int i = 0; i < n; i++) {
    long long cur;
    if (i % 2) {
      process += forest[0][i] * (2 * i - 2) + forest[1][i] * (2 * i - 1);
      cur = travel2[2 * n - i] - travel2[i] +
            (storage2[2 * n - i] - storage2[i]) * i;
    } else {
      process += forest[1][i] * (2 * i - 2) + forest[0][i] * (2 * i - 1);
      cur = travel1[2 * n - i] - travel1[i] +
            (storage1[2 * n - i] - storage1[i]) * i;
    }
    max = max > cur + process ? max : cur + process;
  }
  cout << max;
  return 0;
}
