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 + 7;
int a[2][MAXN];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
  }
  long long res1 = 0, res2 = 0, cnt = 0;
  for (int i = 0; i < n; i++) {
    res1 += i * a[0][i];
    cnt++;
  }
  for (int i = n - 1; i >= 0; i--) {
    res1 += cnt * a[1][i];
    cnt++;
  }
  for (int i = 0; i < 2 * n; i++) {
    res2 += i * a[(i % 4 == 0 || i % 4 == 3) ? 0 : 1][i / 2];
  }
  cout << max(res1, res2) << endl;
  return 0;
}
