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 = 300000;
long long n;
long long a[maxn + 5][2];
long long dp[maxn + 5][2];
int main() {
  cin >> n;
  for (int i = 0; i < 2; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%I64d", &a[j][i]);
    }
  }
  dp[n + 1][1] = dp[n + 1][0] = 0;
  long long sum = 0;
  long long Ls = 0, Rs = 0;
  for (int i = n; i >= 1; i--) {
    Ls = Ls + sum + (2 * n - 2 * i + 1) * a[i][1];
    Rs = Rs + sum + (2 * n - 2 * i + 1) * a[i][0];
    dp[i][0] = max(Ls, a[i][1] + dp[i + 1][1] + 2 * sum);
    dp[i][1] = max(Rs, a[i][0] + dp[i + 1][0] + 2 * sum);
    sum += a[i][0] + a[i][1];
  }
  printf("%I64d\n", dp[1][0]);
  return 0;
}
