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;
long long n, a[300005], b[300005], s1[300005], s2[300005], ans1[300005],
    ans2[300005];
int main() {
  scanf("%lld", &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 cur = 0;
  for (int i = 1; i <= n; i++, cur++) {
    if (cur == 0) {
      ans1[cur] = (a[i] * cur);
      s1[cur] = a[i];
    } else {
      ans1[cur] = ans1[cur - 1] + (a[i] * cur);
      s1[cur] = s1[cur - 1] + a[i];
    }
  }
  for (int i = n; i >= 1; i--, cur++) {
    ans1[cur] = ans1[cur - 1] + (b[i] * cur);
    s1[cur] = s1[cur - 1] + b[i];
    if (ans1[cur] < 0) cout << "bal" << endl;
  }
  cur = 2;
  for (int i = 2; i <= n; i++, cur++) {
    ans2[cur] += ans2[cur - 1] + (b[i] * cur);
    s2[cur] = s2[cur - 1] + b[i];
  }
  for (int i = n; i >= 2; i--, cur++) {
    ans2[cur] += ans2[cur - 1] + (a[i] * cur);
    s2[cur] = s2[cur - 1] + a[i];
  }
  cur = 0;
  long long mul = 0, res = 0, mx = 0, tmp;
  for (int i = 1; i <= n; i++, cur += 2) {
    if (i == 1) {
      tmp = ans1[n + n - 1];
      mx = max(tmp, mx);
      res += b[1];
      tmp = ans2[n + n - 1] + res;
      mx = max(tmp, mx);
      mul += 2;
    } else if (i & 1) {
      if ((n + n - 1 - mul) > mul) {
        tmp = (ans1[n + n - 1 - mul] - ans1[mul - 1]) +
              (s1[n + n - 1 - mul] - s1[mul - 1]) * mul + res;
        mx = max(tmp, mx);
      }
      res += a[i] * cur;
      res += b[i] * (cur + 1);
      if ((n + n - 1 - mul) > (mul + 2)) {
        tmp = (ans2[n + n - 1 - mul] - ans2[mul + 2 - 1]) +
              (s2[n + n - 1 - mul] - s2[mul + 2 - 1]) * mul + res;
        mx = max(tmp, mx);
      }
      mul += 2;
    } else {
      res += b[i] * cur;
      res += a[i] * (cur + 1);
    }
  }
  mx = max(res, mx);
  printf("%lld\n", mx);
  return 0;
}
