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 int NMAX = (3e5) + 5;
int n;
int a[NMAX], b[NMAX];
long long sum[NMAX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = n; i >= 1; i--) sum[i] = sum[i + 1] + a[i] + b[i];
  long long s1 = 0, s2 = 0;
  for (int i = 1; i <= n; i++)
    s1 += 1LL * a[i] * (i - 1) + 1LL * b[i] * (2 * n - i);
  for (int i = 1; i <= n; i++)
    s2 += 1LL * b[i] * (i - 1) + 1LL * a[i] * (2 * n - i);
  long long rez = 0;
  long long inainte = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2 == 1) {
      rez = max(rez, s1 + inainte + sum[i] * (i - 1));
      inainte += (2 * i - 2) * a[i];
      inainte += (2 * i - 1) * b[i];
    } else {
      rez = max(rez, s2 + inainte + sum[i] * (i - 1));
      inainte += 1LL * (2 * i - 2) * b[i];
      inainte += 1LL * (2 * i - 1) * a[i];
    }
    s1 -= 1LL * (i - 1) * a[i];
    s1 -= 1LL * (2 * n - i) * b[i];
    s2 -= 1LL * (i - 1) * b[i];
    s2 -= 1LL * (2 * n - i) * a[i];
  }
  cout << rez;
  return 0;
}
