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>
long long int fun(int u[], int v[], int m, int rem) {
  if (rem < 1) {
    return 0;
  } else {
    int in = m - rem;
    int min = 2 * in;
    int i, j;
    long long sum = 0;
    for (int i = in; i < m; i++) {
      sum += min * u[i];
      min++;
    }
    for (int j = m - 1; j >= in; j--) {
      sum += min * v[j];
      min++;
    }
    long long max = sum;
    min = 2 * in;
    sum = min * u[in];
    min++;
    for (j = in; j < m; j++) {
      sum += min * v[j];
    }
    for (i = m - 1; i > in; i--) {
      sum += min * u[i];
    }
    if (max < sum) {
      max = sum;
    }
    sum = 0;
    int sw = 0;
    for (i = 0; i < in; i++) {
      if (!sw) {
        sum += 2 * i * u[i] + (2 * i + 1) * v[i];
        sw = 1;
      } else {
        sum += 2 * i * v[i] + (2 * i + 1) * u[i];
        sw = 0;
      }
    }
    min = fun(u, v, m, rem - 2);
    max += sum;
    if (max < min) {
      return min;
    } else {
      return max;
    }
  }
}
int main() {
  int k, n;
  long long max;
  scanf("%d", &n);
  int ar[n], br[n];
  for (k = 0; k < n; k++) {
    scanf("%d", &ar[k]);
  }
  for (k = 0; k < n; k++) {
    scanf("%d", &br[k]);
  }
  max = fun(ar, br, n, n);
  printf("%I64d\n", max);
  return 0;
}
