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 = 3e5 + 5, M = 1e5, P = 1e9 + 7;
long long n;
long long a[N], b[N], sum1[N], sum2[N], sum3[N], c[N], d[N];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  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 = 1, j = 0; i <= n; i++, j += 2) {
    if (i & 1)
      sum1[i] = sum1[i - 1] + j * a[i] + (j + 1) * b[i];
    else
      sum1[i] = sum1[i - 1] + j * b[i] + (j + 1) * a[i];
  }
  for (long long i = 1, j = 0; i <= n; i++, j++) {
    sum2[i] = sum2[i - 1] + j * a[i] + (2 * n - j - 1) * b[i];
    c[i] = c[i - 1] + a[i];
  }
  for (long long i = 1, j = 1; i <= n; i++, j++) {
    if (i == 1)
      sum3[i] = sum3[i - 1] + j * b[i];
    else
      sum3[i] = sum3[i - 1] + j * b[i] + (2 * n - j + 1) * a[i];
    d[i] = d[i - 1] + b[i];
  }
  long long ans = 0;
  for (long long i = 1, j = 0; i <= n; i += 2, j += 2) {
    long long res = 0;
    res += sum1[i - 1];
    res += sum2[n] - sum2[i - 1];
    res += j * (c[n] - c[i - 1]) + j * (d[n] - d[i - 1]);
    ans = max(ans, res);
  }
  for (long long i = 2, j = 0; i <= n; i += 2, j += 2) {
    long long res = 0;
    res += sum1[i - 1];
    res += sum3[n] - sum3[i - 1];
    res += j * (c[n] - c[i - 1]) + j * (d[n] - d[i - 1]);
    ans = max(ans, res);
  }
  cout << ans;
  return 0;
}
