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 p[2][300001];
long long a[300001];
long long b[300001];
long long c[300001];
long long d[300001];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> p[0][i];
  for (int i = 0; i < n; i++) cin >> p[1][i];
  long long result1 = 0;
  long long result2 = 0;
  for (int i = 0; i < n; i++) {
    result1 += i * p[0][i];
    result2 += (2 * n - i - 1) * p[0][i];
    result1 += (2 * n - i - 1) * p[1][i];
    result2 += i * p[1][i];
  }
  c[0] = result1;
  d[0] = result2;
  for (int i = 1; i < n; i++) {
    c[i] = c[i - 1] - (i - 1) * p[0][i - 1] - (2 * n - i) * p[1][i - 1];
    d[i] = d[i - 1] - (i - 1) * p[1][i - 1] - (2 * n - i) * p[0][i - 1];
  }
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += p[0][i];
    sum += p[1][i];
  }
  a[0] = sum - p[0][0] - p[1][0];
  for (int i = 1; i < n; i++) {
    a[i] = a[i - 1] - p[0][i] - p[1][i];
  }
  b[0] = p[1][0];
  for (int i = 1; i < n; i++) {
    if (i % 2 == 0)
      b[i] = b[i - 1] + i * 2 * p[0][i] + (i * 2 + 1) * p[1][i];
    else
      b[i] = b[i - 1] + i * 2 * p[1][i] + (i * 2 + 1) * p[0][i];
  }
  long long result = max(result1, b[n - 1]);
  for (int i = 1; i < n; i++) {
    long long temp;
    if (i % 2 == 0) {
      temp = b[i - 1] + c[i] + i * a[i - 1];
    } else
      temp = b[i - 1] + d[i] + i * a[i - 1];
    if (result < temp) result = temp;
  }
  cout << result << endl;
}
