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;
long long sum_l_to_r[2][300005] = {};
long long sum_r_to_l[2][300005] = {};
long long adj[2][300005] = {};
int base[2][300005] = {};
int main(int argc, char **argv) {
  int n, i, j;
  cin >> n;
  for (i = 0; i < 2; i++) {
    for (j = 0; j < n; j++) {
      cin >> base[i][j];
    }
  }
  for (i = 0; i < 2; i++) {
    for (j = n - 1; j >= 0; j--) {
      sum_l_to_r[i][j] = sum_l_to_r[i][j + 1] + j * 1LL * base[i][j];
      sum_r_to_l[i][j] = sum_r_to_l[i][j + 1] + (n - j) * 1LL * base[i][j];
      adj[i][j] = adj[i][j + 1] + base[i][j];
    }
  }
  long long left_sum = 0;
  long long now_max = 0;
  for (i = 0, j = 0; j < n; j++, i ^= 1) {
    long long cur_sum = left_sum;
    cur_sum += (sum_l_to_r[i][j + 1]) + j * 1LL * adj[i][j + 1];
    cur_sum += sum_r_to_l[i ^ 1][j] + (n + j - 1) * 1LL * adj[i ^ 1][j];
    now_max = max(cur_sum, now_max);
    left_sum += base[i ^ 1][j] * 1LL * (j * 2 + 1);
    left_sum += base[i ^ 1][j + 1] * 1LL * (j * 2 + 2);
  }
  cout << now_max << endl;
  return 0;
}
