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], sum123[2][300005], sum321[2][300005], sum111[2][300005],
    n;
void solve() {
  cin >> n;
  long long i, j, sum = 0, ans = 0;
  for (i = 0; i < 2; i++)
    for (j = 0; j < n; j++) cin >> a[i][j];
  for (i = 0; i < 2; i++)
    for (j = n - 1; j >= 0; j--) {
      sum123[i][j] = sum123[i][j + 1] + (j + 1) * a[i][j];
      sum321[i][j] = sum321[i][j + 1] + (n - j) * a[i][j];
      sum111[i][j] = sum111[i][j + 1] + a[i][j];
    }
  for (i = 0, j = 0; j < n; j++, i = 1 - i) {
    long long val = sum;
    val += sum123[i][j] + j * sum111[i][j];
    val += sum321[1 - i][j] + (j + n) * sum111[1 - i][j];
    ans = max(ans, val);
    sum += (j + j + 1) * a[i][j];
    sum += (j + j + 2) * a[1 - i][j];
  }
  for (i = 0; i < n; i++) ans -= (a[0][i] + a[1][i]);
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
