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);
  int n, i, j;
  cin >> n;
  long long a[2][n], s[n], r[n], p, k[n];
  for (i = 0; i < n; i++) cin >> a[0][i];
  for (i = 0; i < n; i++) cin >> a[1][i];
  if (n == 1) {
    cout << a[1][0];
    return 0;
  }
  p = 0;
  for (i = n - 1; i >= 0; i--) {
    p += (a[0][i] + a[1][i]);
    s[i] = p;
  }
  if (n % 2) {
    r[n - 1] = (2 * n - 2) * a[0][n - 1] + (2 * n - 1) * a[1][n - 1];
    r[n - 2] = (2 * n - 1) * a[0][n - 2] + (2 * n - 4) * a[1][n - 2] +
               (2 * n - 3) * a[1][n - 1] + (2 * n - 2) * a[0][n - 1];
  } else {
    r[n - 1] = (2 * n - 1) * a[0][n - 1] + (2 * n - 2) * a[1][n - 1];
    r[n - 2] = (2 * n - 4) * a[0][n - 2] + (2 * n - 1) * a[1][n - 2] +
               (2 * n - 2) * a[1][n - 1] + (2 * n - 3) * a[0][n - 1];
  }
  for (i = n - 3; i >= 0; i--) {
    if (i % 2) {
      r[i] = (2 * i) * a[1][i] + (2 * i + 1) * a[1][i + 1] +
             (2 * n - 1) * a[0][i] + (2 * n - 2) * a[0][i + 1];
      r[i] += (r[i + 2] - 2 * s[i + 2]);
    } else {
      r[i] = (2 * i) * a[0][i] + (2 * i + 1) * a[0][i + 1] +
             (2 * n - 1) * a[1][i] + (2 * n - 2) * a[1][i + 1];
      r[i] += (r[i + 2] - 2 * s[i + 2]);
    }
  }
  k[n - 1] = r[n - 1];
  for (i = n - 2; i >= 0; i--) {
    if (i % 2)
      p = 2 * i * a[1][i] + (2 * i + 1) * a[0][i];
    else
      p = 2 * i * a[0][i] + (2 * i + 1) * a[1][i];
    k[i] = max(r[i], p + k[i + 1]);
  }
  cout << k[0];
  return 0;
}
