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;
const int maxn = 300100;
int n, g[2][maxn];
long long sum[maxn], turn[2][maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < n; j++) cin >> g[i][j];
  for (int i = n - 1; i >= 0; i--) {
    sum[i] = sum[i + 1] + g[0][i] + g[1][i];
    for (int j = 0; j < 2; j++)
      turn[j][i] = sum[i + 1] + turn[j][i + 1] + g[!j][i] * (2 * (n - i) - 1);
  }
  long long ans = 0, acc = 0;
  bool w = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, acc + turn[w][i] + sum[i] * 2 * i);
    acc += g[w][i] * 2 * i + g[!w][i] * (2 * i + 1);
    w = !w;
  }
  cout << ans << endl;
}
