#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300000 + 100;
unsigned long long s[MAXN * 2], all[2][MAXN];
unsigned long long all0[2][MAXN], all1[2][MAXN];
int n, m, ai[2][MAXN], tmp[2][MAXN];
inline unsigned long long cal(int pos, int p);
inline unsigned long long cal1(int pos);
inline unsigned long long cal2(int pos);
inline unsigned long long cal3(int pos, int p);
int main() {
  scanf("%d", &n);
  m = 2 * n;
  for (int j = 0; j <= 1; j++) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &ai[j][i]);
      all[j][i] = all[j][i - 1] + ai[j][i];
    }
  }
  for (int i = 1; i <= n; i++) {
    all0[0][i] = all0[0][i - 1] + (unsigned long long)(i - 1) * ai[0][i];
    all1[1][i] = all1[1][i - 1] + (unsigned long long)(i - 1) * ai[1][i];
  }
  for (int i = n; i; i--) {
    all0[1][i] = all0[1][i + 1] + (unsigned long long)(m - i) * ai[1][i];
    all1[0][i] = all1[0][i + 1] + (unsigned long long)(m - i) * ai[0][i];
  }
  for (int i = 0, x = 0, y = 1; i < m; i++) {
    tmp[x][y] = 1;
    s[i + 1] = s[i] + (unsigned long long)ai[x][y] * i;
    if (tmp[x ^ 1][y]) {
      y++;
    } else {
      x ^= 1;
    }
  }
  unsigned long long ans = 0;
  for (int i = 2, p = 2; i <= n; i += 2, p += 4) {
    ans = max(ans, s[p] + cal3(i, p) + cal2(i));
  }
  for (int i = 1, p = 0; i <= n; i += 2, p += 4) {
    ans = max(ans, s[p] + cal(i, p) + cal1(i));
  }
  cout << ans << endl;
  return 0;
}
inline unsigned long long cal(int pos, int p) {
  unsigned long long tans = all0[0][n] - all0[0][pos - 1];
  tans += ((unsigned long long)p - pos + 1) * (all[0][n] - all[0][pos - 1]);
  return tans;
}
inline unsigned long long cal1(int pos) {
  unsigned long long tans = all0[1][pos];
  tans += ((unsigned long long)pos - 1) * (all[1][n] - all[1][pos - 1]);
  return tans;
}
inline unsigned long long cal2(int pos) {
  unsigned long long tans = all1[0][pos];
  tans += ((unsigned long long)pos - 1) * (all[0][n] - all[0][pos - 1]);
  return tans;
}
inline unsigned long long cal3(int pos, int p) {
  unsigned long long tans = all1[1][n] - all1[1][pos - 1];
  tans += ((unsigned long long)p - pos + 1) * (all[1][n] - all[1][pos - 1]);
  return tans;
}
