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 n, arr[300002][2], sum, best, a, b;
long long prefix[300002][2];
long long line[4];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i][0];
  for (int i = 0; i < n; i++) cin >> arr[i][1];
  for (int i = 0; i < n; i++) prefix[i + 1][0] = prefix[i][0] + arr[i][0];
  for (int i = 0; i < n; i++) prefix[i + 1][1] += prefix[i][1] + arr[i][1];
  for (int i = 0; i < n; i++) {
    line[0] += prefix[n][0] - prefix[i + 1][0];
    line[1] += arr[i][1] * (2 * n - i - 1);
    line[2] += prefix[n][1] - prefix[i + 1][1];
    line[3] += arr[i][0] * (2 * n - i - 1);
  }
  for (int a = 0; a < n; a++) {
    if (a % 2 == 0) {
      best = max(best, sum + line[0] + line[1] +
                           2 * a * (prefix[n][0] - prefix[a][0]) +
                           a * (prefix[n][1] - prefix[a][1]));
      sum += arr[a][0] * (2 * a);
      sum += arr[a][1] * (2 * a + 1);
    } else {
      best = max(best, sum + line[2] + line[3] +
                           2 * a * (prefix[n][1] - prefix[a][1]) +
                           a * (prefix[n][0] - prefix[a][0]));
      sum += arr[a][0] * (2 * a + 1);
      sum += arr[a][1] * (2 * a);
    }
    line[0] -= prefix[n][0] - prefix[a + 1][0];
    line[1] -= arr[a][1] * (2 * n - a - 1);
    line[2] -= prefix[n][1] - prefix[a + 1][1];
    line[3] -= arr[a][0] * (2 * n - a - 1);
  }
  cout << best << endl;
}
