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 main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long n;
  cin >> n;
  long long a[n][2];
  for (long long t = 0; t < 2; t++)
    for (long long i = 0; i < n; i++) cin >> a[i][t];
  long long dp[n][2];
  dp[n - 1][0] = a[n - 1][1];
  dp[n - 1][1] = a[n - 1][0];
  long long sum[n];
  sum[n - 1] = a[n - 1][0] + a[n - 1][1];
  for (long long i = n - 2; i >= 0; i--) {
    dp[i][0] = dp[i + 1][0] + a[i][1] * ((n - 1 - i) * 2 + 1);
    dp[i][1] = dp[i + 1][1] + a[i][0] * ((n - 1 - i) * 2 + 1);
    dp[i][0] += sum[i + 1];
    dp[i][1] += sum[i + 1];
    sum[i] = sum[i + 1] + a[i][0] + a[i][1];
  }
  long long ans = 0;
  long long x = 0;
  long long y = 0;
  long long t = 0;
  long long suma = 0;
  while (x < n) {
    suma += t * a[x][y];
    if (x % 2 == 0) {
      if (y == 0) {
        if (x + 1 < n)
          ans = max(ans, suma + dp[x + 1][y] + sum[x + 1] * (t + 1) +
                             a[x][1] * (2 * n - 1));
        y++;
      } else {
        if (x + 1 < n)
          ans = max(ans, suma + dp[x + 1][y] + sum[x + 1] * (t + 1));
        x++;
      }
    } else {
      if (y == 0) {
        if (x + 1 < n)
          ans = max(ans, suma + dp[x + 1][y] + sum[x + 1] * (t + 1));
        x++;
      } else {
        if (x + 1 < n)
          ans = max(ans, suma + dp[x + 1][y] + sum[x + 1] * (t + 1) +
                             a[x][0] * (2 * n - 1));
        y--;
      }
    }
    t++;
  }
  ans = max(ans, suma);
  cout << ans << "\n";
}
