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 main() {
  int n;
  cin >> n;
  long long **glade = new long long *[2];
  for (int i = 0; i < 2; i++) {
    glade[i] = new long long[n + 1];
    for (int j = 0; j <= n; j++) glade[i][j] = 0;
  }
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      cin >> glade[i][j];
    }
  }
  long long **l_to_r = new long long *[2];
  long long **r_to_l = new long long *[2];
  long long **growth = new long long *[2];
  for (int i = 0; i < 2; i++) {
    l_to_r[i] = new long long[n + 1];
    for (int j = 0; j <= n; j++) l_to_r[i][j] = 0;
  }
  for (int i = 0; i < 2; i++) {
    r_to_l[i] = new long long[n + 1];
    for (int j = 0; j <= n; j++) r_to_l[i][j] = 0;
  }
  for (int i = 0; i < 2; i++) {
    growth[i] = new long long[n + 1];
    for (int j = 0; j <= n; j++) growth[i][j] = 0;
  }
  for (int i = 0; i < 2; i++) {
    for (int j = n - 1; j >= 0; j--) {
      l_to_r[i][j] = l_to_r[i][j + 1] + (j) * (glade[i][j]);
      r_to_l[i][j] = r_to_l[i][j + 1] + (n - j) * (glade[i][j]);
      growth[i][j] = growth[i][j + 1] + glade[i][j];
    }
  }
  long long ans = 0, sum = 0;
  for (int i = 0, j = 0; j < n; i = i ^ 1, j++) {
    long long poss_ans = sum;
    poss_ans += l_to_r[i][j] + growth[i][j] * (j);
    poss_ans += r_to_l[i ^ 1][j] + growth[i ^ 1][j] * (n + j - 1);
    ans = max(ans, poss_ans);
    sum += glade[i][j] * (j + j);
    sum += glade[i ^ 1][j] * (j + j + 1);
  }
  cout << ans << endl;
  return 0;
}
