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 long long N = 300005;
long long n, sum, ans, a[N], b[N], sa[N][2], sb[N][2], ta[N][2], tb[N][2];
long long calc(long long i, long long bg, long long f) {
  if (i > n) {
    return 0;
  }
  if (f == 0) {
    return ta[i][1] + (bg - i) * ta[i][0] + sb[i][1] +
           (bg + 2 * (n - i + 1) - 1 - (n - i + 1)) * sb[i][0];
  } else {
    return tb[i][1] + (bg - i) * tb[i][0] + sa[i][1] +
           (bg + 2 * (n - i + 1) - 1 - (n - i + 1)) * sa[i][0];
  }
}
signed main() {
  scanf("%I64d", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
  }
  for (long long i = 1; i <= n; i++) {
    scanf("%I64d", &b[i]);
  }
  for (long long i = n; i >= 1; i--) {
    sa[i][0] = sa[i + 1][0] + a[i];
    sa[i][1] = sa[i + 1][1] + (n - i + 1) * a[i];
    sb[i][0] = sb[i + 1][0] + b[i];
    sb[i][1] = sb[i + 1][1] + (n - i + 1) * b[i];
    ta[i][0] = ta[i + 1][0] + a[i];
    ta[i][1] = ta[i + 1][1] + i * a[i];
    tb[i][0] = tb[i + 1][0] + b[i];
    tb[i][1] = tb[i + 1][1] + i * b[i];
  }
  for (long long i = 1; i <= n; i++) {
    if (i & 1) {
      ans = max(ans, sum + calc(i, 2 * i - 2, 0));
      ans = max(ans, sum + a[i] * (2 * i - 2) + b[i] * (2 * i - 1) +
                         calc(i + 1, 2 * i, 1));
      sum += a[i] * (2 * i - 2) + b[i] * (2 * i - 1);
    } else {
      ans = max(ans, sum + calc(i, 2 * i - 2, 1));
      ans = max(ans, sum + b[i] * (2 * i - 2) + a[i] * (2 * i - 1) +
                         calc(i + 1, 2 * i, 0));
      sum += b[i] * (2 * i - 2) + a[i] * (2 * i - 1);
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
