#include <bits/stdc++.h>
using namespace std;
int get() {
  char ch;
  while (!((ch = getchar() - 48) >= 0))
    ;
  int v = ch;
  while (((ch = getchar() - 48) >= 0)) v = (v << 1) + (v << 3) + ch;
  return v;
}
int n, a[300005], b[300005];
long long s[300005], s1[300005], s2[300005], sum, ans;
int main() {
  n = get();
  for (int i = 1; i <= n; i++) a[i] = get();
  for (int i = 1; i <= n; i++) b[i] = get();
  for (int i = n; i; i--) {
    s[i] = s[i + 1] + a[i] + b[i];
    s1[i] = s1[i + 1] + s[i + 1] + (long long)b[i] * ((n - i + 1) * 2 - 1);
    s2[i] = s2[i + 1] + s[i + 1] + (long long)a[i] * ((n - i + 1) * 2 - 1);
  }
  bool f = 0;
  for (int i = 1; i <= n; i++, f ^= 1) {
    if (!f) {
      ans = max(ans, sum + s1[i]);
      sum += b[i] + s[i + 1] * 2;
    } else {
      ans = max(ans, sum + s2[i]);
      sum += a[i] + s[i + 1] * 2;
    }
  }
  cout << ans << endl;
  return 0;
}
