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;
const long long MOD = 1000000007;
const long long INF = 1000000007;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
string gh = "here";
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<vector<long long> > v1(2, vector<long long>(n + 2, 0));
  vector<long long> ss(n + 2, 0), nss(n + 2, 0), ssn(n + 2, 0);
  for (long long i = 1; i <= n; i++) {
    cin >> v1[0][i];
  }
  for (long long i = 1; i <= n; i++) {
    cin >> v1[1][i];
  }
  for (long long i = n; i > 0; i--) {
    ss[i] = ss[i + 1];
    ss[i] += v1[0][i] + v1[1][i];
  }
  for (long long i = n; i > 0; i--) {
    nss[i] = nss[i + 1] + ss[i + 1];
    ;
    nss[i] += v1[0][i] + (2 * (n - i + 1)) * (v1[1][i]);
  }
  for (long long i = n; i > 0; i--) {
    ssn[i] = ssn[i + 1] + ss[i + 1];
    ssn[i] += v1[1][i] + (2 * (n - i + 1)) * (v1[0][i]);
  };
  ;
  ;
  long long ans = 0, ea = 0, t = -1;
  for (long long i = 1; i <= n; i++) {
    if (i % 2) {
      long long qw = ans, wq = ans;
      qw += t * (ss[i]) + nss[i];
      wq += (t + 1) * v1[0][i] + (t + 2) * v1[1][i];
      t += 2;
      ea = max(ea, max(qw, wq));
      ans = wq;
    } else {
      long long qw = ans, wq = ans;
      qw += t * (ss[i]) + ssn[i];
      wq += (t + 2) * v1[0][i] + (t + 1) * v1[1][i];
      t += 2;
      ea = max(ea, max(qw, wq));
      ans = wq;
    }
  }
  cout << ea << '\n';
  return 0;
}
