#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double eps = 1e-6;
inline int lowbit(int x) { return x & (-x); }
inline int read() {
  int f = 1, x = 0;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (ch < '0' || ch > '9');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return f * x;
}
template <typename T>
inline T max(T x, T y, T z) {
  return max(max(x, y), z);
}
template <typename T>
inline T min(T x, T y, T z) {
  return min(min(x, y), z);
}
template <typename T>
inline T sqr(T x) {
  return x * x;
}
template <typename T>
inline void checkmax(T &x, T y) {
  x = max(x, y);
}
template <typename T>
inline void checkmin(T &x, T y) {
  x = min(x, y);
}
template <typename T>
inline void read(T &x) {
  x = 0;
  T f = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (ch < '0' || ch > '9');
  do x = x * 10 + ch - '0', ch = getchar();
  while (ch <= '9' && ch >= '0');
  x *= f;
}
template <typename A, typename B, typename C>
inline A fpow(A x, B p, C yql) {
  A ans = 1;
  for (; p; p >>= 1, x = 1LL * x * x % yql)
    if (p & 1) ans = 1LL * x * ans % yql;
  return ans;
}
struct FastIO {
  static const int S = 1310720;
  int wpos;
  char wbuf[S];
  FastIO() : wpos(0) {}
  inline int xchar() {
    static char buf[S];
    static int len = 0, pos = 0;
    if (pos == len) pos = 0, len = fread(buf, 1, S, stdin);
    if (pos == len) return -1;
    return buf[pos++];
  }
  inline int read() {
    int c = xchar(), x = 0;
    while (c <= 32 && ~c) c = xchar();
    if (c == -1) return -1;
    for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
    return x;
  }
} io;
const int N = 300010;
long long a[N], b[N], suma[N], sumb[N], xa[N], xb[N], ans, t;
int n, m, cnt;
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i++) b[i] = read();
  reverse(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++)
    suma[i] = suma[i - 1] + a[i], xa[i] = xa[i - 1] + suma[i];
  reverse(a + 1, a + n + 1);
  for (int i = n; i; i--)
    suma[i] = suma[i + 1] + a[i], xa[i] = xa[i + 1] + suma[i];
  reverse(b + 1, b + n + 1);
  for (int i = 1; i <= n; i++)
    sumb[i] = sumb[i - 1] + b[i], xb[i] = xb[i - 1] + sumb[i];
  reverse(b + 1, b + n + 1);
  for (int i = n; i; i--)
    sumb[i] = sumb[i + 1] + b[i], xb[i] = xb[i + 1] + sumb[i];
  for (int i = 1; i <= n; i++) t += a[i] + b[i];
  long long cur = 0, res = 0;
  int cnt = 0;
  ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2 != 0) {
      cur = res + xa[i] - xb[i];
      cur += (i - 1) * 2 * suma[i] + (n - i + 2) * sumb[i];
      cur += (i - 1 + n) * sumb[i];
      checkmax(ans, cur);
      cnt++;
      res += 1LL * cnt * a[i];
      cur = res + b[i] - xa[i + 1];
      cur += (i * 2 - 1) * sumb[i] + (n - i + 1) * suma[i + 1];
      cur += (i + n) * suma[i + 1];
      checkmax(ans, cur);
      cnt++;
      res += 1LL * cnt * b[i];
    } else {
      cur = res + xb[i] - xa[i];
      cur += (i - 1) * 2 * sumb[i] + (n - i + 2) * suma[i];
      cur += (i - 1 + n) * suma[i];
      checkmax(ans, cur);
      cnt++;
      res += 1LL * cnt * b[i];
      cur = res + xa[i] - xb[i + 1];
      cur += (i * 2 - 1) * suma[i] + (n - i + 1) * sumb[i + 1];
      cur += (i + n) * sumb[i + 1];
      checkmax(ans, cur);
      cnt++;
      res += 1LL * cnt * a[i];
    }
  }
  cout << ans - t << endl;
}
