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, t;
long long up[300005], down[300005];
long long a[300005][2];
long long maxn;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i][0];
  for (int i = 0; i < n; i++) cin >> a[i][1];
  for (int i = 0; i < n; i++, t++) down[0] += a[i][0] * t;
  for (int i = n - 1; i >= 0; i--, t++) down[0] += a[i][1] * t;
  maxn = down[0];
  for (int i = 2; i < n; i += 2) {
    down[i] = down[i - 2] + 2 * (a[i - 1][0] + a[i][0] + a[i][1]) -
              2 * a[i - 1][1] - 4 * a[i - 2][1];
    maxn = max(maxn, down[i]);
  }
  t = 1;
  for (int i = 0; i < n; i++, t++) up[1] += a[i][1] * t;
  for (int i = n - 1; i > 0; i--, t++) up[1] += a[i][0] * t;
  for (int i = 3; i < n; i += 2) {
    up[i] = up[i - 2] + 2 * (a[i - 1][1] + a[i][0] + a[i][1]) -
            2 * a[i - 1][0] - 4 * a[i - 2][0];
    maxn = max(maxn, up[i]);
  }
  cout << maxn;
  return 0;
}
