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 = (int)2e6 + 10;
const int inf = (int)2e9;
int n;
long long rate[3][N], ans = 0;
void F(int i, int j, int cnt, int rgt, long long moves) {
  if (j > n) return;
  ans += rate[i][j] * moves;
  if (rgt) {
    F(i, j + 1, cnt, 0, moves + 1);
  } else {
    if (cnt % 2 == 0) {
      F(i + 1, j, cnt + 1, 1, moves + 1);
    } else {
      F(i - 1, j, cnt + 1, 1, moves + 1);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &rate[1][i]);
  for (int i = 1; i <= n; i++) scanf("%lld", &rate[2][i]);
  long long mx = 0, t = 0, sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += t * rate[1][i];
    t += 1;
  }
  for (int i = n; i >= 1; i--) {
    sum += t * rate[2][i];
    t += 1;
  }
  mx = max(mx, sum);
  F(1, 1, 0, 0, 0);
  mx = max(mx, ans);
  printf("%lld\n", mx);
  return 0;
}
