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 gcd(long long a, long long b) {
  if (a == 0LL) return b;
  return gcd(b, a % b);
}
const int N = 300005;
long long grid[2][N];
long long sum[2][N];
long long pre[2][N], suf[2][N];
long long prepre[2][N], sufsuf[2][N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < 2; i++) {
    pre[i][0] = 0;
    for (int j = 1; j <= n; j++) {
      cin >> grid[i][j];
      pre[i][j] = pre[i][j - 1] + grid[i][j];
    }
    suf[i][n + 1] = 0;
    for (int j = n; j >= 1; j--) suf[i][j] = suf[i][j + 1] + grid[i][j];
    prepre[i][0] = 0;
    for (int j = 1; j <= n; j++) prepre[i][j] = prepre[i][j - 1] + pre[i][j];
    sufsuf[i][n + 1] = 0;
    for (int j = n; j >= 1; j--) sufsuf[i][j] = sufsuf[i][j + 1] + suf[i][j];
  }
  long long ans =
      sufsuf[0][1] - suf[0][1] + prepre[1][n] + (n - 1LL) * pre[1][n];
  long long cur = 1LL * grid[1][1];
  for (int i = 2; i <= n; i++) {
    ans =
        max(ans, cur + sufsuf[!(i & 1)][i] - suf[!(i & 1)][i] +
                     (i - 1) * 2LL * suf[!(i & 1)][i] + prepre[i & 1][n] -
                     prepre[i & 1][i - 1] - (n - i + 1LL) * pre[i & 1][i - 1] +
                     suf[i & 1][i] * ((i - 1) * 2LL + n - i));
    cur +=
        2LL * (i - 1LL) * grid[!(i & 1)][i] + (2LL * i - 1LL) * grid[i & 1][i];
  }
  cout << max(ans, cur) << "\n";
  return 0;
}
