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;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<vector<long long>> v(2, vector<long long>(n + 2, 0)),
      pref(2, vector<long long>(n + 2, 0));
  for (long long i = 0; i < 2; ++i)
    for (long long j = 0; j < n; ++j) cin >> v[i][j];
  for (long long i = 0; i < 2; ++i) {
    long long prev = 0;
    for (long long j = 0; j < n; ++j) {
      prev += v[i][j];
      pref[i][j] = prev;
    }
  }
  vector<vector<long long>> inc(2, vector<long long>(n + 2, 0)),
      dec(2, vector<long long>(n + 2, 0));
  for (long long i = 0; i < 2; ++i) {
    long long cur1 = 0, cur2 = 0;
    for (long long j = n - 1; j >= 0; j--) {
      cur1 += v[i][j] * (n - j);
      dec[i][j] = cur1;
      cur2 += v[i][j] * (j + 1);
      inc[i][j] = cur2;
    }
  }
  auto rangeSum = [&](long long row, long long left, long long right) {
    long long s = pref[row][right];
    if (left > 0) s -= pref[row][left - 1];
    return s;
  };
  auto sumInc = [&](long long row, long long left, long long mul) {
    long long s = inc[row][left];
    long long cur = left + 1;
    long long need = mul - cur;
    long long second = rangeSum(row, left, n - 1);
    return s + second * need;
  };
  auto sumDec = [&](long long row, long long left, long long mul) {
    long long s = dec[row][left];
    long long cur = 1;
    long long need = mul - cur;
    long long second = rangeSum(row, left, n - 1);
    return s + second * need;
  };
  long long ans = 0;
  long long prev = 0;
  long long node = 0;
  for (long long i = 0; i < n; ++i) {
    if (i % 2) {
      prev += v[1][i] * node;
      prev += v[0][i] * (node + 1);
    } else {
      long long r0 = sumInc(0ll, i, node);
      long long r1 = sumDec(1, i, 2 * n - (n - i));
      ans = max(ans, prev + r0 + r1);
      if (i + 1 < n) {
        r1 = sumInc(1, i, node);
        r0 = sumDec(0, i + 1, 2 * n - (n - i - 1));
        ans = max(ans, prev + r0 + r1);
      }
      prev += v[0][i] * node;
      prev += v[1][i] * (node + 1);
    }
    node += 2;
  }
  ans = max(ans, prev);
  cout << ans;
  return 0;
}
