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;
const int maxn = 3e5 + 10;
int n;
long long a[maxn], b[maxn];
long long sum1[2][maxn], sum2[2][maxn], pre[2][maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    pre[0][i] = a[i] + pre[0][i - 1];
  }
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &b[i]);
    pre[1][i] = b[i] + pre[1][i - 1];
  }
  for (int i = 1; i <= n; i++) {
    sum1[0][i] = (i - 1) * a[i] + sum1[0][i - 1];
    sum1[1][i] = (i - 1) * b[i] + sum1[1][i - 1];
  }
  for (int i = 1; i <= n; i++) {
    sum2[0][i] = (2 * n - i) * a[i] + sum2[0][i - 1];
    sum2[1][i] = (2 * n - i) * b[i] + sum2[1][i - 1];
  }
  long long s1 = 0;
  long long ans = sum1[0][n] + sum2[1][n];
  long long t1 = sum1[0][n] + sum2[1][n];
  long long t2 = sum2[0][n] + sum1[1][n];
  long long pres = pre[0][n] + pre[1][n];
  for (int i = 1; i <= n; i++) {
    if (i % 2) {
      s1 += (i - 1) * 2 * a[i] + ((i - 1) * 2 + 1) * b[i];
      ans = max(ans, s1 + t2 - sum2[0][i] - sum1[1][i] +
                         i * (pres - pre[0][i] - pre[1][i]));
    } else {
      s1 += (i - 1) * 2 * b[i] + ((i - 1) * 2 + 1) * a[i];
      ans = max(ans, s1 + t1 - sum1[0][i] - sum2[1][i] +
                         i * (pres - pre[0][i] - pre[1][i]));
    }
  }
  cout << ans << endl;
  return 0;
}
