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 dp1[2][1000001];
long long dp2[2][1000001];
long long dp3[2][1000001];
long long dp4[2][1000001];
long long arr[1000001], brr[1000001];
long long func(int i, int j, int n, int t) {
  if (j == n + 1) return 0;
  long long ans;
  if (i == 0)
    return max(
        dp1[1][j] - dp1[0][j - 1] + (t - (j - 1)) * (dp3[1][j] - dp3[0][j - 1]),
        arr[j] * t + brr[j] * (t + 1) + func(1, j + 1, n, t + 2));
  else
    return max(
        dp2[0][j] - dp2[1][j - 1] + (t - (j - 1)) * (dp4[0][j] - dp4[1][j - 1]),
        arr[j] * (t + 1) + brr[j] * t + func(0, j + 1, n, t + 2));
}
int main() {
  dp1[0][0] = 0;
  dp2[1][0] = 0;
  dp3[0][0] = 0;
  dp4[1][0] = 0;
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> arr[i];
  for (int i = 1; i <= n; ++i) cin >> brr[i];
  for (int i = 1; i <= n; ++i) {
    dp1[0][i] = dp1[0][i - 1] + (i - 1) * arr[i];
    dp2[1][i] = dp2[1][i - 1] + (i - 1) * brr[i];
    dp3[0][i] = dp3[0][i - 1] + arr[i];
    dp4[1][i] = dp4[1][i - 1] + brr[i];
  }
  dp1[1][n] = n * brr[n] + dp1[0][n];
  dp2[0][n] = n * arr[n] + dp2[1][n];
  dp3[1][n] = brr[n] + dp3[0][n];
  dp4[0][n] = arr[n] + dp4[1][n];
  for (int i = n - 1; i > 0; --i) {
    dp1[1][i] = dp1[1][i + 1] + (2 * n - i) * brr[i];
    dp2[0][i] = dp2[0][i + 1] + (2 * n - i) * arr[i];
    dp3[1][i] = dp3[1][i + 1] + brr[i];
    dp4[0][i] = dp4[0][i + 1] + arr[i];
  }
  cout << func(0, 1, n, 0);
}
