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;
int a[300000], b[300000];
long long int ans, ans2;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);
  long long int sum_a_b = 0;
  for (int i = 0; i < n; i++) sum_a_b += a[i] + b[i];
  long long int sum_u_d = 0, sum_d_u = 0;
  long long int ai, bi;
  ;
  for (int i = 0; i < n; i++) {
    ai = a[i];
    bi = b[i];
    sum_u_d += i * ai + (n + n - 1 - i) * bi;
    sum_d_u += (n + n - 1 - i) * ai + i * bi;
  }
  ans = sum_u_d;
  long long x = 0, y = 1;
  ans2 = 0;
  for (int i = 0; i < n; i++) {
    ai = a[i];
    bi = b[i];
    ans2 += x * ai;
    ans2 += y * bi;
    if (i & 1) {
      x += 1;
      y += 3;
    } else {
      x += 3;
      y += 1;
    }
    sum_u_d -= i * ai + (n + n - 1 - i) * bi;
    sum_d_u -= (n + n - 1 - i) * ai + i * bi;
    sum_a_b -= ai + bi;
    if (i & 1) {
      ans = max(ans, ans2 + sum_u_d + sum_a_b * (i + 1));
    } else {
      ans = max(ans, ans2 + sum_d_u + sum_a_b * (i + 1));
    }
  }
  cout << ans << endl;
  return 0;
}
