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 + 5;
int n, a[N], b[N];
long long s[N], ans = 0, cur = 0, u[N], v[N];
void solve() {
  for (int i = 1; i <= n; ++i) s[i] = s[i - 1] + a[i] + b[i];
  for (int i = 1; i <= n; ++i) u[i] = u[i - 1] + (long long)(i - 1) * a[i];
  for (int i = 1, j = n + n - 1; i <= n; ++i, --j)
    v[i] = v[i - 1] + (long long)j * b[i];
  for (int i = 0, j = -1, k = 0; i <= n; i += 2, j += 4, k += 2) {
    if (i)
      cur += (long long)j * a[i] + (long long)(j - 1) * b[i] +
             (long long)(j - 2) * b[i - 1] + (long long)(j - 3) * a[i - 1];
    ans = max(ans, cur + u[n] + v[n] - u[i] - v[i] + (s[n] - s[i]) * k);
  }
  cur = b[1];
  for (int i = 1, j = 1, k = 0; i <= n; i += 2, j += 4, k += 2) {
    if (i > 1)
      cur += (long long)j * b[i] + (long long)(j - 1) * a[i] +
             (long long)(j - 2) * a[i - 1] + (long long)(j - 3) * b[i - 1];
    ans = max(ans, cur + u[n] + v[n] - u[i] - v[i] + (s[n] - s[i]) * k);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) cin >> b[i];
  solve();
  cout << ans << "\n";
  return 0;
}
