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 n, a[300005], b[300005], ans[6][300005], sum, res, kq, tmp1, tmp2;
int main() {
  cin >> n;
  for (long long i = (1); i <= (n); ++i) cin >> a[i];
  for (long long i = (1); i <= (n); ++i) cin >> b[i];
  sum = a[n] + b[n];
  ans[1][n] = ans[2][n] = ans[3][n] = b[n];
  ans[4][n] = ans[5][n] = a[n];
  kq = b[n];
  res = 2;
  for (long long i = (n - 1); i >= (1); --i) {
    res += 2;
    tmp2 = max(ans[4][i + 1], ans[5][i + 1]);
    tmp1 = max(max(ans[1][i + 1], ans[2][i + 1]), ans[3][i + 1]);
    ans[1][i] = ans[1][i + 1] + sum + b[i] * (res - 1);
    ans[2][i] = b[i] + tmp2 + 2 * sum;
    ans[3][i] = b[i] + tmp2 + 2 * sum;
    ans[4][i] = ans[4][i + 1] + sum + a[i] * (res - 1);
    ans[5][i] = tmp1 + 2 * sum + a[i];
    kq = max(kq, tmp2 + 2 * sum + b[i]);
    kq = max(kq, ans[1][i]);
    sum += a[i] + b[i];
  }
  cout << kq;
  return 0;
}
