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;
int n;
long long ans;
long long a[3][300005];
long long s[3][300005];
long long f[300005];
int getnw(int pos) { return (pos == 1) ? 2 : 1; }
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) cin >> a[1][i], s[1][i] = s[1][i - 1] + a[1][i];
  for (i = 1; i <= n; i++) cin >> a[2][i], s[2][i] = s[2][i - 1] + a[2][i];
  ans = 0;
  long long cnt = 0;
  long long tim = 0;
  for (i = 1; i <= n; i++) cnt += tim * a[1][i], tim++;
  for (i = n; i >= 1; i--) cnt += tim * a[2][i], tim++;
  ans = max(ans, cnt);
  f[0] = cnt;
  cnt = a[2][1], tim = 2;
  for (i = 2; i <= n; i++) cnt += tim * a[2][i], tim++;
  for (i = n; i >= 2; i--) cnt += tim * a[1][i], tim++;
  ans = max(ans, cnt);
  f[1] = cnt - a[2][1];
  int pos = 2;
  long long x;
  cnt = a[2][1], tim = 2;
  for (i = 2; i <= n; i++) {
    cnt += tim * a[pos][i], tim++;
    pos = (pos == 1) ? 2 : 1;
    cnt += tim * a[pos][i], tim++;
    x = f[i - 2] - (tim - 4) * a[pos][i - 1] - (tim - 3) * a[pos][i] -
        (2 * n - 1) * a[getnw(pos)][i - 1] - (2 * n - 2) * a[getnw(pos)][i];
    f[i] = x + 2 * (s[1][n] - s[1][i] + s[2][n] - s[2][i]);
    ans = max(ans, f[i] + cnt);
  }
  cout << ans << endl;
  return 0;
}
