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;
long long a[2][300005], kum[2][300005], z[300005];
int main() {
  int n;
  cin >> n;
  long long sve = 0;
  for (int i = 0; i < 2; ++i) {
    for (int j = 1; j <= n; ++j) {
      cin >> a[i][j];
      sve += a[i][j];
    }
  }
  for (int i = n; i >= 1; --i) {
    z[i] = z[i + 1] + a[0][i] + a[1][i];
  }
  for (int i = n; i >= 1; --i) {
    for (int j = 0; j < 2; ++j) {
      kum[j][i] =
          kum[j][i + 1] + a[j][i] + a[j ^ 1][i] * (n - i + 1) * 2 + z[i + 1];
    }
  }
  bool sad = 0;
  long long ans = 0, val = 0;
  for (int i = 1; i <= n; ++i) {
    ans = max(ans, val + kum[sad][i] + (i - 1) * 2 * z[i]);
    val += (a[sad][i] * (i * 2 - 1) + a[sad ^ 1][i] * (i * 2));
    sad ^= 1;
  }
  cout << ans - sve;
  return 0;
}
