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 n;
long long ans, a[300010], b[300010], sum1[300010], sum2[300010];
long long s1[300010], s2[300010], s3[300010], s4[300010], sum, A, B;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%I64d", &a[i]), sum1[i] = sum1[i - 1] + a[i];
  for (int i = 1; i <= n; i++)
    scanf("%I64d", &b[i]), sum2[i] = sum2[i - 1] + b[i];
  for (int i = 1; i <= n; i++) {
    s1[i] = s1[i - 1] + (i - 1) * a[i];
    s2[i] = s2[i - 1] + (i - 1) * b[i];
  }
  for (int i = n; i; i--) {
    s3[i] = s3[i + 1] + (n - i) * a[i];
    s4[i] = s4[i + 1] + (n - i) * b[i];
  }
  for (int i = 1; i <= n; i++) {
    if (i & 1) {
      A = s1[n] - s1[i - 1] + (sum1[n] - sum1[i - 1]) * (i - 1);
      B = s4[i] + (sum2[n] - sum2[i - 1]) * (i - 1 + n);
      ans = max(ans, sum + A + B);
      sum += (i - 1) * 2 * a[i];
      A = s2[n] - s2[i - 1] + (sum2[n] - sum2[i - 1]) * i;
      B = s3[i + 1] + (sum1[n] - sum1[i]) * (i + n);
      ans = max(ans, sum + A + B);
      sum += (i * 2 - 1) * b[i];
    } else {
      A = s2[n] - s2[i - 1] + (sum2[n] - sum2[i - 1]) * (i - 1);
      B = s3[i] + (sum1[n] - sum1[i - 1]) * (i - 1 + n);
      ans = max(ans, sum + A + B);
      sum += (i - 1) * 2 * b[i];
      A = s1[n] - s1[i - 1] + (sum1[n] - sum1[i - 1]) * i;
      B = s4[i + 1] + (sum2[n] - sum2[i]) * (i + n);
      ans = max(ans, sum + A + B);
      sum += (i * 2 - 1) * a[i];
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
