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;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
const double PI = acos(-1.0);
const long long INF = 1e9 + 47;
const long long LINF = INF * INF;
int n;
long long a[2][1 << 20];
long long sum2[2][1 << 20];
long long sum[2][1 << 20];
long long ans;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int j = 0; j < 2; j++)
    for (int i = 0; i < n; i++) {
      cin >> a[j][i];
    }
  for (int i = 0; i < n; i++) {
    sum[0][i] = a[i % 2][i] * (i * 2) + (i - 1 >= 0 ? sum[1][i - 1] : 0);
    sum[1][i] = a[!(i % 2)][i] * (i * 2 + 1) + sum[0][i];
  }
  long long curSum = 0;
  for (int i = n - 1; i >= 0; i--) {
    int diff = n - i;
    curSum += (n - diff) * a[0][i] + (n + diff - 1) * a[1][i];
    sum2[0][i] = curSum;
  }
  curSum = 0;
  for (int i = n - 1; i >= 0; i--) {
    int diff = n - i;
    curSum += (n - diff) * a[1][i] + (n + diff - 1) * a[0][i];
    sum2[1][i] = curSum;
  }
  ans = max(sum[1][n - 1], sum2[0][0]);
  for (int i = 1; i < n; i++) {
    ans = max(sum2[i % 2][i] + sum[1][i - 1], ans);
  }
  cout << ans;
  return 0;
}
