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;
int a[300005], b[300005];
long long sum[300005], tsum = 0, sum1 = 0, sum2 = 0, ans = 0;
int main(void) {
  int i, n;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (i = 1; i <= n; ++i) scanf("%d", &b[i]);
  for (i = n; i >= 1; --i) sum[i] = sum[i + 1] + a[i] + b[i];
  for (i = 1; i <= n; ++i)
    sum1 += 1LL * (i - 1) * a[i] + 1LL * (2 * n - i) * b[i];
  for (i = 1; i <= n; ++i)
    sum2 += 1LL * (i - 1) * b[i] + 1LL * (2 * n - i) * a[i];
  for (i = 1; i <= n; ++i) {
    if (i & 1) {
      ans = max(ans, tsum + sum1 + 1LL * (i - 1) * sum[i]);
      tsum += 1LL * (2 * i - 2) * a[i] + 1LL * (2 * i - 1) * b[i];
    } else {
      ans = max(ans, tsum + sum2 + 1LL * (i - 1) * sum[i]);
      tsum += 1LL * (2 * i - 2) * b[i] + 1LL * (2 * i - 1) * a[i];
    }
    sum1 -= 1LL * (i - 1) * a[i] + 1LL * (2 * n - i) * b[i];
    sum2 -= 1LL * (i - 1) * b[i] + 1LL * (2 * n - i) * a[i];
  }
  printf("%lld\n", ans);
  return 0;
}
