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 = 3e5 + 10;
int s[2][maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &s[0][i]);
  for (int i = 0; i < n; i++) scanf("%d", &s[1][i]);
  long long ans = 0, sum = 0, t = 0;
  for (int i = 0; i < n; i++) sum += 1ll * s[0][i] * t, t++;
  for (int i = n - 1; i >= 0; i--) sum += 1ll * s[1][i] * t, t++;
  ans = max(ans, sum);
  sum = 0, t = 1;
  int x = 0, y = 0, flag = 1;
  while (y < n) {
    x += flag;
    sum += 1ll * s[x][y] * t;
    t++;
    y++;
    sum += 1ll * s[x][y] * t;
    t++;
    flag = -flag;
  }
  sum += 1ll * s[1 - x][y] * t;
  ans = max(ans, sum);
  sum = 0, t = 1;
  for (int i = 0; i < n; i++) sum += 1ll * s[1][i] * t, t++;
  for (int i = n - 1; i > 0; i--) sum += 1ll * s[0][i] * t, t++;
  ans = max(ans, sum);
  cout << ans << endl;
  return 0;
}
