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;
long long a[300005];
long long b[300005];
long long alla[300005];
long long allb[300005];
long long suma1[300005];
long long suma2[300005];
long long sumb1[300005];
long long sumb2[300005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%lld", &b[i]);
  for (int i = 1; i <= n; i++) {
    suma1[i] = suma1[i - 1] + a[i] * (i - 1);
    sumb2[i] = sumb2[i - 1] + b[i] * (i);
  }
  for (int i = n; i >= 1; i--) {
    alla[i] = alla[i + 1] + a[i];
    allb[i] = allb[i + 1] + b[i];
    if (i != 1)
      suma2[i] = suma2[i + 1] + a[i] * (2 * n - i + 1);
    else
      suma2[i] = suma2[i + 1];
    sumb1[i] = sumb1[i + 1] + b[i] * (2 * n - i);
  }
  long long ans = max(suma1[n] + sumb1[1], suma2[1] + sumb2[n]);
  int k = 1;
  int cnt = 0;
  long long now = 0;
  for (int i = 1; i <= n - 1; i += 2) {
    now += b[i] * k;
    k++;
    now += b[i + 1] * k;
    k++;
    now += a[i + 1] * k;
    k++;
    now += a[i + 2] * k;
    k++;
    cnt++;
    ans = max(ans, max(now + 2 * cnt * (alla[i + 3] + allb[i + 2]) + suma1[n] -
                           suma1[i + 2] + sumb1[i + 2],
                       now + 2 * cnt * (alla[i + 3] + allb[i + 2]) +
                           suma2[i + 3] + sumb2[n] - sumb2[i + 1]));
  }
  cout << ans << endl;
  return 0;
}
