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 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;
}
