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;
void solve() {
  long long n;
  cin >> n;
  long long s1, s2, sum = 0;
  s1 = s2 = 0;
  vector<long long> a(n), b(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    s1 += i * a[i];
    if (i) s2 += (2 * n - i) * a[i];
    sum += a[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> b[i];
    s1 += (2 * n - 1 - i) * b[i];
    s2 += (i + 1) * b[i];
    sum += b[i];
  }
  long long ans = max(s1, s2);
  long long k = b[0];
  s2 -= b[0];
  s1 -= (2 * n - 1) * b[0];
  sum -= a[0];
  sum -= b[0];
  for (long long i = 1; i < n; i++) {
    if (i & 1) {
      k += 2 * i * b[i];
      k += (2 * i + 1) * a[i];
      s1 -= i * a[i];
      s2 -= (2 * n - i) * a[i];
      s1 -= (2 * n - 1 - i) * b[i];
      s2 -= (i + 1) * b[i];
      sum -= a[i];
      sum -= b[i];
      ans = max(ans, k + s1 + (i + 1) * sum);
    } else {
      k += (2 * i + 1) * b[i];
      k += 2 * i * a[i];
      s1 -= i * a[i];
      s2 -= (2 * n - i) * a[i];
      s1 -= (2 * n - 1 - i) * b[i];
      s2 -= (i + 1) * b[i];
      sum -= a[i];
      sum -= b[i];
      ans = max(ans, k + s2 + i * sum);
    }
  }
  cout << ans << '\n';
  ;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tc;
  tc = 1;
  for (int i = 1; i <= tc; i++) {
    solve();
  }
  return 0;
}
