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 inf = 0x3f3f3f3f, mod = 1000000007;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const double pi = acosl(-1.), eps = 1e-9;
inline int power(int a, int b, int m = mod, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
const int NN = 300030;
long long a[2][NN];
long long s[2][NN];
long long t[2][NN];
int n;
long long calc(int d) {
  return t[0][n] - t[0][d - 1] - (s[0][n] - s[0][d - 1]) * (d - 1) + t[1][d] +
         (s[1][n] - s[1][d - 1]) * (n - d + 1);
}
long long sum(int i) { return s[0][n] - s[0][i - 1] + s[1][n] - s[1][i - 1]; }
int main() {
  cin >> n;
  for (int j = 0; j < 2; j++) {
    for (int i = 1; i <= n; i++) {
      scanf("%I64d", &a[j][i]);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 2; j++) {
      s[j][i] = s[j][i - 1] + a[j][i];
    }
  }
  for (int i = 1; i <= n; i++) {
    t[0][i] = t[0][i - 1] + a[0][i] * (i - 1);
  }
  for (int i = n; i; i--) {
    t[1][i] = t[1][i + 1] + a[1][i] * (n - i);
  }
  long long tot = 0;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i & 1) {
      ans = max(ans, 2 * (i - 1) * sum(i) + calc(i) + tot);
      tot += a[0][i] * ((i - 1) * 2) + a[1][i] * ((i - 1) * 2 + 1);
    } else {
      ans = max(ans, 2 * (i - 1) * sum(i) +
                         ((n - i + 1) * 2 - 1) *
                             (s[0][n] + s[1][n] - s[0][i - 1] - s[1][i - 1]) -
                         calc(i) + tot);
      tot += a[1][i] * ((i - 1) * 2) + a[0][i] * ((i - 1) * 2 + 1);
    }
  }
  cout << ans << endl;
  return 0;
}
