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];
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) cin >> a[1][i];
  for (i = 1; i <= n; i++) cin >> 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);
  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);
  int pos = 2;
  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++;
  }
  ans = max(ans, cnt);
  cout << ans << endl;
  return 0;
}
