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>
const double pi = acos(-1.0);
using namespace std;
int a[300010], b[300010];
int suml[300010], sumr[300010];
int sum1[300010], sum2[300010];
int sum[300010];
int n;
void init1() {
  int k = 0;
  suml[0] = 0;
  suml[1] = b[1];
  for (int i = 2; i <= n; i += 2) {
    suml[i] = suml[i - 2] + k * a[i - 1] + (k + 1) * b[i - 1] + (k + 2) * b[i] +
              (k + 3) * a[i];
    k += 4;
  }
  k = 2;
  for (int i = 3; i <= n; i += 2) {
    suml[i] = suml[i - 2] + k * b[i - 1] + (k + 1) * a[i - 1] + (k + 2) * a[i] +
              (k + 3) * b[i];
    k += 4;
  }
  int q = 0;
  k = 2;
  for (int i = 2; i <= n; i++) {
    q += k * b[i];
    k++;
  }
  for (int i = n; i >= 3; i--) {
    q += k * a[i];
    k++;
  }
  sumr[2] = q;
  for (int i = 4; i <= n; i += 2) {
    sumr[i] = sumr[i - 2] - (i - 2) * b[i - 2] - (i - 1) * b[i - 1] -
              (2 * n - i + 2) * a[i - 1] - (2 * n - i + 3) * a[i - 2];
  }
  q = 0;
  k = 0;
  for (int i = 1; i <= n; i++) {
    q += k * a[i];
    k++;
  }
  for (int i = n; i >= 1; i--) {
    q += k * b[i];
    k++;
  }
  sumr[1] = q;
  for (int i = 3; i <= n; i += 2)
    sumr[i] = sumr[i - 2] - (i - 2) * a[i - 2] - (i - 1) * a[i - 1] -
              (2 * n - i + 2) * b[i - 1] - (2 * n - i + 3) * b[i - 2];
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  if (n == 1) {
    cout << b[1];
    return 0;
  }
  if (n == 2) {
    cout << max(a[2] + 2 * b[2] + 3 * b[1], b[1] + 2 * b[2] + 3 * a[2]);
    return 0;
  }
  if (n == 3) {
    cout << max(max(b[1] + 2 * b[2] + 3 * a[2] + 4 * a[3] + 5 * b[3],
                    b[1] + 2 * b[2] + 3 * b[3] + 4 * a[3] + 5 * a[2]),
                a[2] + 2 * a[3] + 3 * b[3] + 4 * b[2] + 5 * b[1]);
    return 0;
  }
  sum1[1] = a[1];
  for (int i = 2; i <= n; i++) sum[i] = sum[i - 1] + a[i];
  sum2[1] = b[1];
  for (int i = 2; i <= n; i++) sum2[i] = sum2[i - 1] + b[i];
  int ans = 0;
  memset((suml), (0), sizeof((suml)));
  memset((sumr), (0), sizeof((sumr)));
  init1();
  for (int i = 1; i <= n; i++) {
    ans = max(ans, suml[i - 1] + sumr[i]);
  }
  cout << ans;
  return 0;
}
