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 = 300005;
int n, a[N], b[N];
long long ans = 0, fi = 0, se = 0, cur = 0, sa[N], sb[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = n; i >= 1; i--) {
    sa[i] = sa[i + 1] + a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  for (int i = n; i >= 1; i--) {
    sb[i] = sb[i + 1] + b[i];
  }
  for (int i = 1; i <= n; i++) {
    fi += 1LL * (i - 1) * a[i] + 1LL * (2 * n - i) * b[i];
    se += 1LL * (i - 1) * b[i] + 1LL * (2 * n - i) * a[i];
  }
  ans = max(ans, fi);
  for (int i = 1; i <= n; i++) {
    fi -= 1LL * (i - 1) * a[i] + 1LL * (2 * n - i) * b[i];
    se -= 1LL * (i - 1) * b[i] + 1LL * (2 * n - i) * a[i];
    if (i & 1) {
      cur += 1LL * (2 * i - 2) * a[i] + 1LL * (2 * i - 1) * b[i];
      ans = max(ans, cur + se + 1LL * i * (sa[i + 1] + sb[i + 1]));
    } else {
      cur += 1LL * (2 * i - 2) * b[i] + 1LL * (2 * i - 1) * a[i];
      ans = max(ans, cur + fi + 1LL * i * (sa[i + 1] + sb[i + 1]));
    }
  }
  cout << ans;
}
