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>
const double PI = acos(-1.0);
using namespace std;
const int maxn = 3e5 + 10;
int n, a[2][maxn];
long long sum[2][maxn], psum[2][maxn];
int main() {
  scanf("%d", &n);
  for (int t = 0; t < 2; t++)
    for (int i = 1; i <= n; i++) scanf("%d", &a[t][i]);
  for (int t = 0; t < 2; t++)
    for (int i = n; i >= 1; i--) sum[t][i] = sum[t][i + 1] + a[t][i];
  for (int t = 0; t < 2; t++)
    for (int i = n; i >= 1; i--) psum[t][i] = psum[t][i + 1] + sum[t][i];
  int t = 0;
  long long ans = 0, pre = 0;
  for (int i = 1; i <= n; i++) {
    if (i & 1) {
      long long tmp = pre;
      tmp += (t - 1) * sum[0][i] + psum[0][i];
      tmp += (n - i + 1) * sum[1][i] - psum[1][i] + (n - i + 1 + t) * sum[1][i];
      ans = max(ans, tmp);
      pre += (t++) * a[0][i];
      tmp = pre;
      tmp += (t - 1) * sum[1][i] + psum[1][i];
      tmp += (n - i) * sum[0][i + 1] - psum[0][i + 1] +
             (n - i + 1 + t) * sum[0][i + 1];
      ans = max(ans, tmp);
      pre += (t++) * a[1][i];
    } else {
      long long tmp = pre;
      tmp += (t - 1) * sum[1][i] + psum[1][i];
      tmp += (n - i + 1) * sum[0][i] - psum[0][i] + (n - i + 1 + t) * sum[0][i];
      ans = max(ans, tmp);
      pre += (t++) * a[1][i];
      tmp = pre;
      tmp += (t - 1) * sum[0][i] + psum[0][i];
      tmp += (n - i) * sum[1][i + 1] - psum[1][i + 1] +
             (n - i + 1 + t) * sum[1][i + 1];
      pre += (t++) * a[0][i];
    }
  }
  cout << ans << endl;
  return 0;
}
