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 = 1e6 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
int n;
int a[N], b[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  while (cin >> n) {
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) cin >> b[i];
    long long ans = 0, cur = 0;
    long long t = 0;
    for (int i = 1; i <= n; ++i) {
      cur += t * a[i];
      t += 1;
    }
    for (int i = n; i >= 1; --i) {
      cur += t * b[i];
      t += 1;
    }
    ans = max(ans, cur);
    cur = t = 0;
    for (int i = 1; i <= n; ++i) {
      if (i & 1) {
        cur += t * a[i];
        t += 1;
        cur += t * b[i];
        t += 1;
      } else {
        cur += t * b[i];
        t += 1;
        cur += t * a[i];
        t += 1;
      }
    }
    ans = max(ans, cur);
    cout << ans << endl;
  }
  return 0;
}
