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 int t, sum, n, i, ma, ml, my, a[2][5000000], cnt1, cnt2, rst;
int main() {
  scanf("%lld", &n);
  for (i = 0; i < n; i++) {
    scanf("%lld", &a[0][i]);
    if (ma <= a[0][i]) {
      ma = a[0][i];
      ml = 0;
      my = i;
    }
  }
  for (i = 0; i < n; i++) {
    scanf("%lld", &a[1][i]);
    if (ma <= a[1][i]) {
      ma = a[1][i];
      ml = 1;
      my = i;
    }
  }
  for (i = 0; i < n; i++) {
    cnt1 += a[0][i] * i;
  }
  for (i = n; i < 2 * n; i++) {
    cnt1 += a[1][2 * n - 1 - i] * i;
  }
  t = 0;
  for (i = 0; i < 2 * n;)
    if (t % 2) {
      cnt2 += a[0][t] * (i++);
      t++;
    } else {
      cnt2 += a[0][t] * i;
      i += 3;
      t++;
    }
  t = 0;
  for (i = 1; i < 2 * n;)
    if (t % 2) {
      cnt2 += a[1][t] * i;
      i += 3;
      t++;
    } else {
      cnt2 += a[1][t] * i;
      i++;
      t++;
    }
  printf("%lld ", cnt1 > cnt2 ? cnt1 : cnt2);
}
