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[5][300005], f[5][300005], sum[5][300005];
long long kq;
int n;
void nhap() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[1][i];
  for (int i = 1; i <= n; ++i) cin >> a[2][i];
  for (int i = n; i >= 1; --i) {
    sum[1][i] = sum[1][i + 1] + a[1][i];
    sum[2][i] = sum[2][i + 1] + a[2][i];
  }
}
void xl() {
  for (int i = 1; i <= n; ++i)
    if (i % 2 == 1) {
      f[1][i] = f[1][i - 1] + (2 * (i - 1)) * a[1][i];
      f[2][i] = f[1][i] + (2 * (i - 1) + 1) * a[2][i];
    } else {
      f[2][i] = f[2][i - 1] + (2 * (i - 1)) * a[2][i];
      f[1][i] = f[2][i] + (2 * (i - 1) + 1) * a[1][i];
    }
  if (n % 2 == 1)
    kq = f[2][n];
  else
    kq = f[1][n];
  long long res1 = 0, res2 = (2 * n - 1) * a[2][n],
            res11 = (2 * n - 1) * a[1][n], res22 = 0;
  for (int i = n; i >= 1; --i) {
    if (i % 2 == 1 && i != n) {
      long long res = (2 * (i - 1)) * sum[1][i];
      res += res1;
      res += res2;
      res += f[1][i - 1];
      kq = max(kq, res);
    } else if (i % 2 == 0 && i != n) {
      long long res = (2 * (i - 1)) * sum[2][i];
      res += res22;
      res += res11;
      res += f[2][i - 1];
      kq = max(kq, res);
    }
    res1 += a[1][i] + sum[1][i + 1];
    res2 -= sum[2][i];
    res2 += (2 * n - 1) * a[2][i - 1];
    res22 += a[2][i] + sum[2][i + 1];
    res11 -= sum[1][i];
    res11 += (2 * n - 1) * a[1][i - 1];
  }
  cout << kq;
}
int main() {
  nhap();
  xl();
  return 0;
}
