#include <bits/stdc++.h>
using namespace std;
void READ() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(8);
}
const int N = 5 + 3e5;
int n, m;
long long sum[N], sum2[N], a[N], b[N], sa1[N], sa2[N], sb1[N], sb2[N], ans;
int main() {
  READ();
  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 = 1; i <= n; i++) {
    if (i % 2)
      sum[i] = sum[i - 1] + a[i] * (2 * i - 2) + b[i] * (2 * i - 1);
    else
      sum[i] = sum[i - 1] + b[i] * (2 * i - 2) + a[i] * (2 * i - 1);
  }
  for (int i = n; i >= 1; i--) {
    sum2[i] = sum2[i + 1] + a[i] + b[i];
    sa1[i] = sa1[i + 1] + (i - 1) * a[i];
    sa2[i] = sa2[i + 1] + (2 * n - i) * a[i];
    sb1[i] = sb1[i + 1] + (i - 1) * b[i];
    sb2[i] = sb2[i + 1] + (2 * n - i) * b[i];
  }
  for (int i = 1; i <= n; i++) {
    if (i % 2)
      ans = max(ans, sum[i - 1] + sa1[i] + sb2[i] + (i - 1) * sum2[i]);
    else {
      ans = max(ans, sum[i - 1] + sa2[i] + sb1[i] + (i - 1) * sum2[i]);
    }
  }
  cout << ans;
  return 0;
}
