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;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long n;
  cin >> n;
  long long a[n], b[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) cin >> b[i];
  long long ans1 = 0, ans2 = 0;
  for (long long i = 0; i < 2 * n; i++) {
    if (i < n)
      ans1 += i * 1ll * a[i];
    else
      ans1 += i * 1ll * b[2 * n - i - 1];
  }
  long long ctr = 0, ctr1 = 0;
  bool f = true;
  for (long long i = 0; i < 2 * n; i = i + 2) {
    if (f) {
      ans2 += i * 1ll * a[ctr++] + (i + 1) * 1ll * b[ctr1++];
    } else
      ans2 += i * 1ll * b[ctr1++] + (i + 1) * 1ll * a[ctr++];
    f = !f;
  }
  cout << max(ans1, ans2) << '\n';
  return 0;
}
