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;
int n;
long long a[2][300001];
long long dpSum[300001];
long long dpR[300001];
long long dpT[300001];
long long dpB[300001];
int getEndingIndex() { return n - (n + 1) % 2; }
void calcDpSum() {
  dpSum[n] = a[0][n] + a[1][n];
  for (int i = n - 1; i > 0; i -= 1) {
    dpSum[i] = dpSum[i + 1];
    dpSum[i] += a[0][i] + a[1][i];
  }
}
long long countCells(int i) { return (n - i + 1) * 2; }
long long sol() {
  long long c;
  long long alt;
  for (int i = getEndingIndex(); i >= 1; i -= 2) {
    if (i == n) {
      dpT[i] = a[1][i];
      dpB[i] = a[0][i];
      dpR[i] = a[1][i];
    } else if (i == n - 1) {
      dpT[i] = a[0][i + 1] + 2 * a[1][i + 1] + 3 * a[1][i];
      dpB[i] = a[1][i + 1] + 2 * a[0][i + 1] + 3 * a[0][i];
      dpR[i] = a[1][i] + 2 * a[1][i + 1] + 3 * a[0][i + 1];
    } else {
      c = countCells(i + 2);
      dpT[i] = a[0][i + 1] + (c + 2) * a[1][i + 1] + (c + 3) * a[1][i];
      dpT[i] += dpT[i + 2] + dpSum[i + 2] * 2;
      dpB[i] = a[1][i + 1] + (c + 2) * a[0][i + 1] + (c + 3) * a[0][i];
      dpB[i] += dpB[i + 2] + dpSum[i + 2] * 2;
      dpR[i] = a[1][i] + 2 * a[1][i + 1] + 3 * a[0][i + 1];
      dpR[i] += dpSum[i + 2] * 4;
      dpR[i] += max(dpR[i + 2], dpT[i + 2]);
      alt = a[1][i] + 2 * a[1][i + 1] + (c + 3) * a[0][i + 1];
      alt += dpB[i + 2] + dpSum[i + 2] * 3;
      dpR[i] = max(dpR[i], alt);
    }
  }
  return max(dpR[1], dpT[1]);
}
int main() {
  scanf("%ld", &n);
  for (int j = 0; j < 2; j++)
    for (int i = 1; i <= n; i++) scanf("%ld", &a[j][i]);
  calcDpSum();
  printf("%lld\n", sol());
  return 0;
}
