#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;
}
