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 oo = 1e9;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> up(n), dw(n);
  for (int i = (0); i < (n); ++i) cin >> up[i];
  for (int i = (0); i < (n); ++i) cin >> dw[i];
  vector<long long> sum(n);
  for (int i = (0); i < (n); ++i) sum[i] = up[i] + dw[i];
  for (int i = (1); i < (n); ++i) sum[n - i - 1] += sum[n - i];
  vector<long long> a(n), b(n);
  for (int i = (0); i < (n); ++i) {
    a[0] += (i * up[i] + (2 * n - i - 1) * dw[i]);
    b[0] += (i * dw[i] + (2 * n - i - 1) * up[i]);
  }
  for (int i = (1); i < (n); ++i) {
    a[i] = a[i - 1] - (2 * (n - i) + 1) * dw[i - 1] - sum[i];
    b[i] = b[i - 1] - (2 * (n - i) + 1) * up[i - 1] - sum[i];
  }
  long long ans = 0, curr = 0;
  for (int i = (0); i < (n); ++i) {
    ans = max(ans, curr + (i % 2 ? b[i] : a[i]) + 2 * i * sum[i]);
    if (i % 2)
      curr += (2 * i) * dw[i] + (2 * i + 1) * up[i];
    else
      curr += (2 * i) * up[i] + (2 * i + 1) * dw[i];
  }
  ans = max(ans, curr);
  cout << ans << '\n';
  return 0;
}
