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 double eps = 1e-6;
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...);
}
const long long N = 3e5 + 2;
long long a[2][N];
long long go[2][N];
long long come[2][N];
long long extra[2][N];
void print(long long n, long long a[]) {}
void solve() {
  long long n;
  cin >> n;
  for (long long i = 0; i < 2; ++i)
    for (long long j = 0; j < n; ++j) cin >> a[i][j];
  for (long long i = 0; i < 2; ++i) {
    for (long long j = n - 1; j >= 0; --j) {
      go[i][j] = go[i][j + 1] + (j + 1) * a[i][j];
      come[i][j] = come[i][j + 1] + (n - j) * a[i][j];
      extra[i][j] = extra[i][j + 1] + a[i][j];
    }
  }
  long long i = 0;
  long long zigzag = 0;
  long long ans = 0;
  for (long long j = 0; j < n; ++j) {
    long long res = zigzag;
    res = res + go[i][j] + j * extra[i][j];
    res = res + come[i ^ 1][j] + (n + j) * extra[i ^ 1][j];
    ans = max(ans, res);
    zigzag += (2 * j + 1) * a[i][j];
    zigzag += (2 * j + 2) * a[i ^ 1][j];
    i ^= 1;
  }
  for (long long i = 0; i < n; ++i) ans -= a[0][i] + a[1][i];
  cout << ans << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t = 1;
  while (t--) solve();
}
