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 N;
long long av[2][300005], bv[2][300005], cv[2][300005], dv[2][300005];
void readin() {
  scanf("%d", &N);
  for (int j = 0; j < 2; ++j) {
    for (int i = 1; i <= N; ++i) {
      scanf("%I64d", &av[j][i]);
      bv[j][i] = bv[j][i - 1] + av[j][i];
      cv[j][i] = (N - i + 1) * av[j][i] + cv[j][i - 1];
    }
  }
}
long long query(long long *a, int l, int r) { return a[r] - a[l - 1]; }
long long get_odd(long long t, int i) {
  long long ans = 0LL, ret = 0;
  ans += t * query(bv[0], i + 1, N) + dv[0][i + 1];
  ans += (t + N - i) * query(bv[1], i, N) + query(cv[1], i, N);
  ret = max(ret, ans);
  ans = 0LL;
  ans += t * query(bv[1], i, N) + dv[1][i];
  ans += (t + N - i + 1) * query(bv[0], i + 1, N) + query(cv[0], i + 1, N);
  ret = max(ret, ans);
  return ret;
}
long long get_even(long long t, int i) {
  long long ret = 0, ans = 0LL;
  ans += t * query(bv[0], i + 1, N) + dv[0][i + 1];
  ans += (t + N - i) * query(bv[1], i + 1, N) + query(cv[1], i + 1, N);
  ret = max(ret, ans);
  return ret;
}
long long move_next(long long &t, int i) {
  long long ret = 0LL;
  if (i == N) {
    return ret;
  } else if (i % 2 == 1) {
    ret += (++t) * av[1][i];
    ret += (++t) * av[1][i + 1];
    ret += (++t) * av[0][i + 1];
  } else {
    ret += (++t) * av[0][i + 1];
  }
  return ret;
}
void process() {
  long long t = 0, ans = 0LL, acc = 0LL;
  for (int j = 0; j < 2; ++j) {
    t = 0;
    for (int i = N; i >= 1; --i) {
      t += av[j][i];
      dv[j][i] = dv[j][i + 1] + t;
    }
  }
  t = 0;
  for (int i = 1; i <= N; ++i) {
    if (i % 2 == 1) {
      ans = max(ans, acc + get_odd(t, i));
    } else {
      ans = max(ans, acc + get_even(t, i));
    }
    acc += move_next(t, i);
  }
  printf("%I64d\n", ans);
}
int main() {
  readin();
  process();
  return 0;
}
