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() {}
const long long maxn = 300500;
long long n;
long long a[2][maxn];
long long pref[2][maxn], suf[2][maxn];
long long psa[2][maxn];
long long f(long long i, long long j, long long time) {
  if (j == n + 1) {
    return 0;
  }
  long long val = f(i ^ 1, j + 1, time + 2) + a[i ^ 1][j] * (time + 1) +
                  a[i ^ 1][j + 1] * (time + 2);
  long long val2 = (pref[i][n] - pref[i][j]) +
                   (time - j) * (psa[i][n] - psa[i][j]) + suf[i ^ 1][j] +
                   (time + n - j) * (psa[i ^ 1][n] - psa[i ^ 1][j - 1]);
  return max(val, val2);
}
signed main() {
  ios::sync_with_stdio(0);
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i <= 1; i++) {
    for (long long j = 1; j <= n; j++) {
      cin >> a[i][j];
      psa[i][j] = psa[i][j - 1] + a[i][j];
    }
  }
  for (long long i = 0; i <= 1; i++) {
    for (long long j = 1; j <= n; j++) {
      pref[i][j] = pref[i][j - 1] + a[i][j] * j;
      suf[i][n - j + 1] = suf[i][n - j + 2] + a[i][n - j + 1] * j;
    }
  }
  for (long long i = 0; i <= 1; i++) {
    for (long long j = 1; j <= n; j++) {
      if (false) cerr << suf[i][j] << " ";
    }
    if (false) cerr << '\n';
  }
  cout << f(0, 1, 0) << '\n';
}
