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;
using ll = long long;
using ull = unsigned long long;
int n;
ll a[300005];
ll b[300005];
ll p1[600005], p2[600005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    p1[i] = (ll)a[i] * (i - 1);
    p2[2 * n - i + 1] = (ll)a[i] * (2 * n - i);
  }
  for (int i = 1; i <= n; ++i) {
    cin >> b[i];
    p1[2 * n - i + 1] = (ll)b[i] * (2 * n - i);
    p2[i] = (ll)b[i] * (i - 1);
  }
  for (int i = 1; i <= 2 * n; ++i) {
    p1[i] += p1[i - 1], p2[i] += p2[i - 1];
  }
  ll ans = p1[2 * n], t = 0, curr = 0;
  for (int i = 1; i <= n; ++i) {
    if (i & 1) {
      curr += a[i] * t++;
      curr += b[i] * t++;
      ans = max(ans, curr + p2[2 * n - i] - p2[i]);
    } else {
      curr += b[i] * t++;
      curr += a[i] * t++;
      ans = max(ans, curr + p1[2 * n - i] - p1[i]);
    }
  }
  cout << ans << endl;
  return 0;
}
