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;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  vector<vector<long long> > v(2, vector<long long>(n));
  for (long long i = 0; i < n; i++) cin >> v[0][i];
  for (long long i = 0; i < n; i++) cin >> v[1][i];
  long long lans = 0;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    lans += i * v[0][i];
  }
  for (long long i = n - 1; i >= 0; i--) {
    lans += (n + (n - 1 - i)) * v[1][i];
  }
  ans = lans;
  lans = 0;
  for (long long i = 0; i < n; i++) {
    lans += (i + 1) * v[1][i];
  }
  for (long long i = n - 1; i >= 1; i--) {
    lans += (n + 1 + (n - 1 - i)) * v[0][i];
  }
  ans = max(ans, lans);
  lans = 0;
  for (long long i = 0; i < n; i++) {
    if (i % 2 == 0) {
      lans += (i * 2) * v[0][i];
      lans += (i * 2 + 1) * v[1][i];
    } else {
      lans += (i * 2) * v[1][i];
      lans += (i * 2 + 1) * v[0][i];
    }
  }
  ans = max(ans, lans);
  cout << ans;
  return 0;
}
