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 MAXN = 4e5;
int n;
long long a[MAXN][2];
long long p[MAXN][2];
long long pr[MAXN][2];
long long s[MAXN][2];
inline void init() {}
inline void solve() {
  init();
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i][0];
  }
  for (long long i = 0; i < n; i++) {
    cin >> a[i][1];
  }
  for (long long i = n - 1; i >= 0; i--) {
    pr[i][0] = (i != n - 1 ? pr[i + 1][0] : 0ll) + a[i][0] * (n - i - 1);
    pr[i][1] = (i != n - 1 ? pr[i + 1][1] : 0ll) + a[i][1] * (n - i - 1);
  }
  long long s0 = 0, s1 = 0;
  for (long long i = n - 1; i >= 0; i--) {
    p[i][0] = (i != n - 1 ? p[i + 1][0] : 0ll) + s0;
    p[i][1] = (i != n - 1 ? p[i + 1][1] : 0ll) + s1;
    s0 += a[i][0];
    s1 += a[i][1];
    s[i][0] = s0;
    s[i][1] = s1;
  }
  long long current = 0;
  for (long long i = 0; i < 2 * n; i++) {
    long long x = i / 2;
    long long cur;
    if (i % 4 == 0) {
      cur = p[x][0] + s[x][0] * i + pr[x][1] + s[x][1] * (n + x) + current;
      ans = max(ans, cur);
      current += a[x][0] * i;
    }
    if (i % 4 == 1) {
      cur = p[x][1] + s[x][1] * i + pr[x + 1][0] + s[x + 1][0] * (n + x) +
            current;
      ans = max(ans, cur);
      current += a[x][1] * i;
    }
    if (i % 4 == 2) {
      cur = p[x][1] + s[x][1] * i + pr[x][0] + s[x][0] * (n + x) + current;
      ans = max(ans, cur);
      current += a[x][1] * i;
    }
    if (i % 4 == 3) {
      cur = p[x][0] + s[x][0] * i + pr[x + 1][1] + s[x + 1][1] * (n + x) +
            current;
      ans = max(ans, cur);
      current += a[x][0] * i;
    }
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  while (cin >> n) solve();
  return 0;
}
