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 N = 300005;
int n;
int a[N], b[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) scanf("%d", &b[i]);
  long long ans = 0, re = 0;
  for (int i = 2; i <= n; ++i) re += (long long)(i - 1) * a[i];
  for (int i = 1; i <= n; ++i) re += (long long)(2 * n - i) * b[i];
  ans = max(ans, re);
  re = 0;
  for (int i = 1; i <= n; ++i) re += (long long)i * b[i];
  for (int i = 2; i <= n; ++i) re += (long long)(2 * n - i + 1) * a[i];
  ans = max(ans, re);
  re = 0;
  int x = 1, y = 1, t = 0;
  for (int i = 2; i <= n * 2; ++i) {
    ++t;
    if (y == 1 && x % 2 == 0) {
      ++x;
    } else if (y == 2 && x & 1) {
      ++x;
    } else if (y == 1) {
      ++y;
    } else {
      --y;
    }
    re += (long long)t * (y == 1 ? a[x] : b[x]);
  }
  ans = max(ans, re);
  printf("%lld\n", ans);
  return 0;
}
