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 a[500001];
int b[500001];
long long sum[500001];
long long dpUp[500001];
long long dpDown[500001];
int main() {
  int n;
  long long maximum = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> b[i];
  }
  for (int i = n; i >= 1; --i) {
    sum[i] = sum[i + 1] + a[i] + b[i];
    dpUp[i] = dpUp[i + 1] + sum[i + 1] + (2 * (n - i) + 1) * b[i];
    dpDown[i] = dpDown[i + 1] + sum[i + 1] + (2 * (n - i) + 1) * a[i];
  }
  maximum = dpUp[1];
  long long soFar = 0;
  for (int i = 1; i <= n; ++i) {
    if (i % 2) {
      soFar += (i - 1) * 2 * a[i];
      soFar += ((i - 1) * 2 + 1) * b[i];
      maximum = max(maximum, soFar + dpDown[i + 1]);
    } else {
      soFar += (i - 1) * 2 * b[i];
      soFar += ((i - 1) * 2 + 1) * a[i];
      maximum = max(maximum, soFar + dpUp[i + 1]);
    }
  }
  cout << maximum;
  return 0;
}
