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;
struct Key {
  long long N, p;
  bool operator==(const Key& other) const {
    return (N == other.N && p == other.p);
  }
};
struct KeyHasher {
  size_t operator()(const Key& k) const { return k.N * 59 + k.p * 61; }
};
unordered_map<Key, long long, KeyHasher> dp;
vector<long long> A, B, C, D, c, d;
long long tell(vector<long long>& f, vector<long long>& s, long long n,
               long long i, long long j) {
  if (i == n) return 0;
  if (dp[{i, j}]) return dp[{i, j}];
  long long a = 0, b = 0, t = 2 * i;
  if (j == 0) {
    a = t * f[i] + (t + 1) * s[i] + tell(f, s, n, i + 1, 1);
    b = C[i] + t * (c[2 * n - i] - c[i]);
    return dp[{i, j}] = max(a, b);
  }
  a = t * s[i] + (t + 1) * f[i] + tell(f, s, n, i + 1, 0);
  b = D[i] + t * (d[2 * n - i] - d[i]);
  return dp[{i, j}] = max(a, b);
}
int main() {
  long long n;
  cin >> n;
  vector<long long> f(n), s(n);
  c.push_back(0);
  d.push_back(0);
  for (long long i = 0; i < n; i++) {
    cin >> f[i];
    A.push_back(f[i]);
  }
  for (long long i = 0; i < n; i++) cin >> s[i];
  for (long long i = n - 1; i >= 0; i--) A.push_back(s[i]);
  for (auto it : A) c.push_back(c[c.size() - 1] + it);
  B = A;
  reverse(B.begin(), B.end());
  for (auto it : B) d.push_back(d[d.size() - 1] + it);
  long long j = n, k = n + 1, y = 0;
  for (long long i = 0; i < n; i++) {
    long long val = c[k] - c[j] + (y * s[n - i - 1]);
    if (C.size()) val += C[C.size() - 1];
    C.push_back(val);
    j--;
    k++;
    y += 2;
  }
  reverse(C.begin(), C.end());
  j = n, k = n + 1, y = 0;
  for (long long i = 0; i < n; i++) {
    long long val = d[k] - d[j] + (y * f[n - i - 1]);
    if (D.size()) val += D[D.size() - 1];
    D.push_back(val);
    j--;
    k++;
    y += 2;
  }
  reverse(D.begin(), D.end());
  cout << tell(f, s, n, 0, 0);
  return 0;
}
