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>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
namespace Dup4 {
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar()) f ^= (c == '-');
  for (; isdigit(c); c = getchar()) x = x * 10 + (c - '0');
  return x * (f ? 1 : -1);
}
template <typename T>
inline void read(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar()) f ^= (c == '-');
  for (; isdigit(c); c = getchar()) x = x * 10 + (c - '0');
  x *= f ? 1 : -1;
}
template <typename T>
inline void out(T x) {
  if (!x) {
    putchar(48);
    return;
  }
  if (x < 0) x = -x, putchar('-');
  int bit[20], i, p = 0;
  for (; x; x /= 10) bit[++p] = x % 10;
  for (i = p; i; --i) putchar(bit[i] + 48);
}
template <typename T>
inline void output(T x) {
  out(x), putchar('\n');
}
template <typename T>
inline T gcd(T a, T b) {
  while (b ^= a ^= b ^= a %= b)
    ;
  return a;
}
const double PI = acos(-1.0);
const double EI = exp(1.0);
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3fll;
}  // namespace Dup4
using namespace Dup4;
namespace FastIO {
bool IOerror = false;
inline char NC() {
  static char buf[10000005], *p1 = buf + 10000005, *pend = buf + 10000005;
  if (p1 == pend) {
    p1 = buf;
    pend = buf + fread(buf, 1, 10000005, stdin);
    if (pend == p1) {
      IOerror = true;
      return -1;
    }
  }
  return *p1++;
}
inline bool blank(char ch) {
  return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
}
inline void __read(char &x) {
  char ch;
  while (blank(ch = NC()))
    ;
  if (IOerror) {
    x = -1;
    return;
  }
  x = ch;
}
template <typename T>
inline void __read(T &x) {
  char ch;
  while (blank(ch = NC()))
    ;
  if (IOerror) {
    x = -1;
    return;
  }
  bool flag = false;
  if (ch == '-') {
    flag = true;
    ch = NC();
  }
  if (!isdigit(ch))
    while (!isdigit(ch = NC()))
      ;
  for (x = ch - '0'; isdigit(ch = NC()); x = x * 10 + ch - '0')
    ;
  if (flag) x *= -1;
}
}  // namespace FastIO
using namespace FastIO;
const int maxn = (int)3e5 + 10;
const int Maxn = (int)1e4 + 10;
const int MOD = (int)1e9 + 7;
int n;
long long a[maxn], b[maxn];
long long ans;
long long prefix_a[maxn], prefix_b[maxn];
long long suffix_a[maxn], suffix_b[maxn];
long long sum_a[maxn], sum_b[maxn];
inline bool Input() {
  if (__read(n), n == EOF) return false;
  for (int i = (1); i <= (n); ++i) __read(a[i]);
  for (int i = (1); i <= (n); ++i) __read(b[i]);
  sum_a[0] = sum_b[0] = 0;
  for (int i = (1); i <= (n); ++i) sum_a[i] = a[i] + sum_a[i - 1];
  for (int i = (1); i <= (n); ++i) sum_b[i] = b[i] + sum_b[i - 1];
  return true;
}
inline long long work1() {
  long long pos = 0;
  prefix_a[0] = 0;
  suffix_b[n + 1] = 0;
  for (int i = (1); i <= (n); ++i)
    prefix_a[i] = prefix_a[i - 1] + (pos++) * a[i];
  for (int i = (n); i >= (1); --i)
    suffix_b[i] = suffix_b[i + 1] + (pos++) * b[i];
  return prefix_a[n] + suffix_b[1];
}
inline long long work2() {
  long long pos = 1;
  prefix_b[0] = 0;
  suffix_a[n + 1] = 0;
  for (int i = (1); i <= (n); ++i)
    prefix_b[i] = prefix_b[i - 1] + (pos++) * b[i];
  for (int i = (n); i >= (2); --i)
    suffix_a[i] = suffix_a[i + 1] + (pos++) * a[i];
  suffix_a[1] = suffix_a[2];
  return prefix_b[n] + suffix_a[1];
}
inline long long work3() {
  long long tot = 0, tmp = 0, ans = 0, pos = 0;
  for (int i = (1); i <= (n); ++i) {
    if (i & 1) {
      tmp += (pos++) * a[i];
      tmp += (pos++) * b[i];
      tot = tmp + (prefix_b[n] - prefix_b[i]) +
            (pos - i - 1) * (sum_b[n] - sum_b[i]) + suffix_a[i + 1] +
            (i - 1) * (sum_a[n] - sum_a[i]);
      ans = max(ans, tot);
    } else {
      tmp += (pos++) * b[i];
      tmp += (pos++) * a[i];
      tot = tmp + (prefix_a[n] - prefix_a[i]) +
            (pos - i - 1) * (sum_a[n] - sum_a[i]) + suffix_b[i + 1] +
            (i - 1) * (sum_b[n] - sum_b[i]);
      ans = max(ans, tot);
    }
  }
  return ans;
}
inline void Solve() {
  ans = 0;
  ans = max(ans, work1());
  ans = max(ans, work2());
  ans = max(ans, work3());
  output(ans);
}
int main() {
  while (Input()) Solve();
  return 0;
}
