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 = 300100;
long long d[2][N], s1[2][N], s2[2][N], s3[2][N], s4[2][N];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 0; i < 2; ++i) {
    for (long long j = 0; j < n; ++j) {
      cin >> d[i][j];
    }
  }
  long long t = 1;
  s3[0][0] = d[0][0], s3[1][0] = d[1][0];
  s4[0][n - 1] = d[0][n - 1], s4[1][n - 1] = d[1][n - 1];
  for (long long i = 1; i < n; ++i) {
    s1[0][i] = s1[0][i - 1] + d[0][i] * t;
    s1[1][i] = s1[1][i - 1] + d[1][i] * (t++);
    s3[0][i] = s3[0][i - 1] + d[0][i];
    s3[1][i] = s3[1][i - 1] + d[1][i];
  }
  t = 1;
  for (long long i = n - 2; i >= 0; --i) {
    s2[0][i] = s2[0][i + 1] + d[0][i] * t;
    s2[1][i] = s2[1][i + 1] + d[1][i] * (t++);
    s4[0][i] = s4[0][i + 1] + d[0][i];
    s4[1][i] = s4[1][i + 1] + d[1][i];
  }
  long long ans = 0, cnt = 0;
  cnt = s1[0][n - 1] + s2[1][0] + n * s4[1][0];
  ans = max(ans, cnt);
  t = 0;
  cnt = 0;
  for (long long i = 0; i < n; ++i) {
    if (i % 2 == 0) {
      cnt += d[0][i] * t + d[1][i] * (t + 1);
      ++ ++t;
      if (i != n - 1) {
        long long k = cnt +
                      (s1[1][n - 1] - s1[1][i] - (i + 1 - t) * s4[1][i + 1]) +
                      (t + n - i - 1) * s4[0][i + 1] + s2[0][i + 1];
        ans = max(ans, k);
      }
    } else {
      cnt += d[1][i] * t + d[0][i] * (t + 1);
      ++ ++t;
      if (i != n - 1) {
        long long k = cnt +
                      (s1[0][n - 1] - s1[0][i] - (i + 1 - t) * s4[0][i + 1]) +
                      (t + n - i - 1) * s4[1][i + 1] + s2[1][i + 1];
        ans = max(ans, k);
      }
    }
  }
  ans = max(ans, cnt);
  cout << ans;
  return 0;
}
