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 n;
int ar1[300005];
int ar2[300005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < (n); i++) {
    cin >> ar1[i];
  }
  for (int j = 0; j < (n); j++) {
    cin >> ar2[j];
  }
  if (n == 1) {
    cout << ar2[0] << "\n";
    return 0;
  }
  int ans = 0;
  int curAns = 0;
  for (int i = 0; i < (n); i++) {
    curAns += i * ar1[i];
  }
  for (int i = 0; i < (n); i++) {
    curAns += (n + i) * ar2[n - i - 1];
  }
  ans = curAns;
  curAns = 0;
  for (int i = 0; i < (n); i++) {
    curAns += (i + 1) * ar2[i];
  }
  for (int i = (1); i < (n); i++) {
    curAns += (n + i) * ar1[n - i];
  }
  ans = max(ans, curAns);
  curAns = 0;
  for (int i = 0; i < (2 * n); i++) {
    if (i % 4 == 0 || i % 4 == 1) {
      if (i % 2 == 0) {
        curAns += i * (ar1[i / 2]);
      } else {
        curAns += i * (ar2[i / 2]);
      }
    } else {
      if (i % 2 == 0) {
        curAns += i * (ar2[i / 2]);
      } else {
        curAns += i * (ar1[i / 2]);
      }
    }
  }
  ans = max(ans, curAns);
  cout << ans << "\n";
  return 0;
}
