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>
const double pi = 4.0 * atan(1.0);
const double e = exp(1.0);
const int maxn = 1e6 + 8;
const long long mod = 1e9 + 7;
const unsigned long long base = 1e7 + 7;
using namespace std;
long long a[2][maxn];
long long d[2];
int main() {
  long long n;
  scanf("%lld", &n);
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%lld", &a[i][j]);
    }
  }
  long long sum = 0;
  long long t = 0;
  for (int i = 0; i < n; i++) {
    sum += t * a[0][i];
    t++;
  }
  for (int i = n - 1; i >= 0; i--) {
    sum += t * a[1][i];
    t++;
  }
  long long sum2 = 0;
  t = 2;
  sum2 += a[1][0];
  for (int i = 1; i < n; i++) {
    sum2 += t * a[1][i];
    t++;
  }
  for (int i = n - 1; i >= 1; i--) {
    sum2 += t * a[0][i];
    t++;
  }
  long long ans = max(sum, sum2);
  long long s = n % 2;
  long long cnt = 0;
  if (s == 1) {
    d[0] = d[1] = a[1][n - 1];
    cnt += a[0][n - 1] + a[1][n - 1];
  }
  long long g = (n / 2) * 2 - 2;
  long long x[5];
  long long p[2];
  for (; g >= 0; g -= 2) {
    x[1] = 0;
    x[2] = 1;
    x[3] = (n - g) * 2ll - 2ll;
    x[4] = (n - g) * 2ll - 1ll;
    cout << x[3] << ' ' << x[4] << endl;
    p[0] = 4ll * cnt + a[1][g] + 2ll * a[1][g + 1] + 3ll * a[0][g + 1];
    p[1] = 2ll * cnt + a[0][g + 1] + x[3] * a[1][g + 1] + x[4] * a[1][g];
    d[1] = max(d[1] + p[0], d[0] + p[0]);
    d[0] = p[1] + d[0];
    cnt += a[0][g] + a[0][g + 1] + a[1][g] + a[1][g + 1];
  }
  ans = max(max(d[1], d[0]), ans);
  cout << ans << endl;
}
