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 N = 3e5 + 7;
int t[2][N];
long long s[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  long long a = 0, b = 0, x = 0, res;
  cin >> n;
  for (int i = 0; i < 2; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> t[i][j];
    }
  }
  for (int i = n; i > 0; i--) {
    s[i] = s[i + 1] + t[0][i] + t[1][i];
  }
  for (int i = 1; i <= n; i++) {
    b += a * t[0][i];
    a++;
  }
  for (int i = n; i > 0; i--) {
    b += a * t[1][i];
    a++;
  }
  res = b;
  a = 0;
  for (int i = 2; i <= n; i += 2) {
    b -= x + a * t[0][i - 1] + (a + 1) * t[0][i] +
         (long long)1 * (n + n - 2) * t[1][i] +
         (long long)1 * (n + n - 1) * t[1][i - 1];
    b += s[i + 1] * 2;
    x += a * t[0][i - 1];
    x += (a + 1) * t[1][i - 1];
    x += (a + 2) * t[1][i];
    x += (a + 3) * t[0][i];
    a += 4;
    b += x;
    if (b > res) res = b;
  }
  b = 0;
  a = 1;
  for (int i = 1; i <= n; i++) {
    b += a * t[1][i];
    a++;
  }
  for (int i = n; i > 1; i--) {
    b += a * t[0][i];
    a++;
  }
  if (b > res) res = b;
  a = 2;
  x = t[1][1];
  for (int i = 3; i <= n; i += 2) {
    b -= x + a * t[1][i - 1] + (a + 1) * t[1][i] +
         (long long)1 * (n + n - 2) * t[0][i] +
         (long long)1 * (n + n - 1) * t[0][i - 1];
    b += s[i + 1] * 2;
    x += a * t[1][i - 1];
    x += (a + 1) * t[0][i - 1];
    x += (a + 2) * t[0][i];
    x += (a + 3) * t[1][i];
    a += 4;
    b += x;
    if (b > res) res = b;
  }
  cout << res;
  return 0;
}
