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 double EPS = (1e-7);
int dcmp(long double a, long double b) {
  return fabs(a - b) <= EPS ? 0 : a < b ? -1 : 1;
}
struct Double {
  long double d;
  Double() { d = 0.0; };
  Double(long double d) : d(d) {}
  bool operator<(const Double& D) const { return dcmp(d, D.d) < 0; }
  bool operator>(const Double& D) const { return dcmp(d, D.d) > 0; }
  bool operator==(const Double& D) const { return dcmp(d, D.d) == 0; }
};
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
const int N = 2e5 + 100;
const int M = 1e7 + 100;
const int MX = 1e6 + 100;
const long long MOD = 1e9 + 7;
void solve() {
  int n;
  cin >> n;
  vector<long long> a(n), b(n);
  long long sum1 = 0, sum2 = 0;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  int curtime = 0;
  for (int i = 0; i < n; ++i) sum1 += curtime++ * a[i];
  for (int j = n - 1; j >= 0; --j) sum1 += curtime++ * b[j];
  curtime = 0;
  int pos = 0;
  for (int i = 0; i < 2 * n; ++i) {
    switch (i % 4) {
      case 0:
        sum2 += curtime++ * a[pos];
        break;
      case 1:
        sum2 += curtime++ * b[pos];
        break;
      case 2:
        pos++;
        sum2 += curtime++ * b[pos];
        break;
      case 3:
        sum2 += curtime++ * a[pos];
        pos++;
        break;
    }
  }
  cout << max(sum1, sum2) << '\n';
}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc = 1;
  while (tc--) solve();
}
