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;
long long a[2][300010];
int main() {
  scanf("%lld", &n);
  for (long long i = (long long)(0); i < (long long)(2); i++)
    for (long long j = (long long)(0); j < (long long)(n); j++)
      scanf("%lld", &a[i][j]);
  long long res = -1e18, suma = 0, sumb = 0;
  for (long long j = (long long)(0); j < (long long)(n); j++) {
    sumb += a[0][j] * j + a[1][j] * (2 * n - 1 - j);
  }
  for (long long j = (long long)(0); j < (long long)(n + 1); j++) {
    res = (res > suma + sumb ? res : suma + sumb);
    if (j < n) {
      sumb -= a[0][j] * j + a[1][j] * (2 * n - 1 - j);
      if (j % 2 == 0) {
        suma += a[0][j] * (2 * j) + a[1][j] * (2 * j + 1);
      } else {
        suma += a[1][j] * (2 * j) + a[0][j] * (2 * j + 1);
      }
    }
  }
  cout << res << endl;
  return 0;
}
