#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;
}
