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 maxn = 300050;
long long suf[maxn];
long long solve(long long *a, long long *b, long long n) {
  long long sum = 0;
  for (long long i = 1; i <= n; ++i) sum += a[i] * (i - 1);
  for (long long i = 1; i <= n; ++i) sum += b[i] * (n * 2 - i);
  suf[n + 1] = 0;
  for (long long i = n; i >= 1; --i) {
    suf[i] = suf[i + 1] + a[i] + b[i];
  }
  long long ans = sum;
  for (long long i = 2; i <= n; i += 2) {
    sum = sum - a[i - 1] * (i * 2 - 4) - a[i] * (i * 2 - 3) -
          b[i - 1] * (n * 2 - 1) - b[i] * (n * 2 - 2);
    sum = sum + a[i - 1] * (i * 2 - 4) + b[i - 1] * (i * 2 - 3) +
          b[i] * (i * 2 - 2) + a[i] * (i * 2 - 1);
    sum = sum + suf[i + 1] * 2;
    ans = max(ans, sum);
  }
  return ans;
}
long long a[maxn], b[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%lld", a + i);
  for (int i = 1; i <= n; ++i) scanf("%lld", b + i);
  long long ans = solve(a, b, n);
  long long t = b[1] + solve(b + 1, a + 1, n - 1);
  ans = max(ans, t);
  cout << ans << endl;
  return 0;
}
