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 main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  long long int v[3][n + 5];
  for (long long int i = 1; i < n + 1; i++) {
    cin >> v[1][i];
  }
  for (long long int i = 1; i < n + 1; i++) {
    cin >> v[2][i];
  }
  long long int pp = 0;
  long long int prefix[n + 5];
  for (long long int i = n; i > 0; i--) {
    pp += (v[1][i] + v[2][i]);
    prefix[i] = pp;
  }
  long long int y[3][n + 5];
  long long int maxi = 0;
  for (long long int i = 1; i < n + 1; i++) {
    y[1][i] = i;
    y[2][i] = 2 * n - i + 1;
  }
  long long int y_sum[n + 5];
  pp = 0;
  for (long long int i = n; i > 0; i--) {
    pp += y[1][i] * v[1][i];
    pp += y[2][i] * v[2][i];
    y_sum[i] = pp;
  }
  long long int z[3][n + 5];
  z[1][1] = 1;
  z[2][1] = 2;
  for (long long int i = 2; i < n + 1; i++) {
    z[1][i] = 2 * n - i + 2;
    z[2][i] = i + 1;
  }
  long long int z_sum[n + 5];
  pp = 0;
  for (long long int i = n; i > 0; i--) {
    pp += z[1][i] * v[1][i];
    pp += z[2][i] * v[2][i];
    z_sum[i] = pp;
  }
  maxi = max(y_sum[1], z_sum[1]);
  if (n == 1) {
    long long int o = v[2][1];
    cout << o << endl;
    return 0;
  }
  long long int c = 1;
  long long int cursum = 0;
  for (int i = 2; i <= n; i += 2) {
    long long int u = (c) * (v[1][i - 1]) + (c + 1) * (v[2][i - 1]) +
                      (c + 2) * (v[2][i]) + (c + 3) * (v[1][i]);
    c += 4;
    cursum += u;
    long long int y = cursum;
    if (i != n) y = y + y_sum[i + 1] + i * prefix[i + 1];
    maxi = max(y, maxi);
  }
  c = 3;
  cursum = 1 * v[1][1] + 2 * v[2][1];
  for (int i = 3; i <= n; i += 2) {
    long long int u = c * v[2][i - 1] + (c + 1) * v[1][i - 1] +
                      (c + 2) * v[1][i] + (c + 3) * (v[2][i]);
    c += 4;
    cursum += u;
    long long int y = cursum;
    if (i != n) {
      y = y + z_sum[i + 1] + (i - 1) * prefix[i + 1];
    }
    maxi = max(y, maxi);
  }
  maxi -= prefix[1];
  cout << maxi << endl;
}
