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 long N = 333333;
long long a[N], b[N], t[N][2], val[N][2];
long long sumb[N], sb[N], suma[N], sa[N];
long long sumbr[N], sbr[N], sumar[N], sar[N];
long long n;
signed main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (long long i = (1); i <= (n); i++) {
    cin >> a[i];
  }
  for (long long i = (1); i <= (n); i++) {
    cin >> b[i];
  }
  for (long long i = (n); i >= (1); i--) {
    sumb[i] = b[i] + sumb[i + 1];
    sb[i] = sb[i + 1] + sumb[i];
    suma[i] = a[i] + suma[i + 1];
    sa[i] = sa[i + 1] + suma[i];
    sar[i] = sar[i + 1] + (n - i + 1) * a[i];
    sbr[i] = sbr[i + 1] + (n - i + 1) * b[i];
  }
  for (long long i = (1); i <= (n); i++) {
    sumar[i] = sumar[i - 1] + a[i];
    sumbr[i] = sumbr[i - 1] + b[i];
  }
  long long cur = 0, ans = 0;
  for (long long i = (1); i <= (n); i++) {
    long long t = (i - 1) * 2;
    long long aft;
    if (i & 1) {
      aft = sa[i] + sbr[i] + (sumar[n] - sumar[i - 1]) * (t - 1) +
            (sumbr[n] - sumbr[i - 1]) * (t + n - i);
    } else {
      aft = sar[i] + sb[i] + (sumar[n] - sumar[i - 1]) * (t + n - i) +
            (sumbr[n] - sumbr[i - 1]) * (t - 1);
    }
    ans = max(ans, cur + aft);
    if (i & 1) {
      cur += t * a[i] + (t + 1) * b[i];
    } else {
      cur += t * b[i] + (t + 1) * a[i];
    }
  }
  ans = max(ans, cur);
  cout << ans << "\n";
  return 0;
}
