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;
  int arr[2][n];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) cin >> arr[i][j];
  }
  long long int r1, r2, r3;
  r1 = 0, r2 = 0, r3 = 0;
  int cont = 0;
  for (int i = 0; i < n; i++) {
    r1 += (cont * arr[0][i]);
    cont++;
  }
  for (int i = n - 1; i >= 0; i--) {
    r1 += (cont * arr[1][i]);
    cont++;
  }
  cont = 1;
  for (int i = 0; i < n; i++) {
    r2 += (cont * arr[1][i]);
    cont++;
  }
  for (int i = n - 1; i >= 1; i--) {
    r2 += cont * (arr[0][i]);
    cont++;
  }
  cont = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      r3 += (cont * arr[0][i]);
      cont++;
      r3 += (cont * arr[1][i]);
      cont++;
    } else {
      r3 += (cont * arr[1][i]);
      cont++;
      r3 += (cont * arr[0][i]);
      cont++;
    }
  }
  cout << max(r1, max(r2, r3)) << "\n";
  return 0;
}
