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 main() {
  int n;
  cin >> n;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  int t1 = 0, t2 = 1, t31 = 0, t32 = 1;
  int s1 = 0, s2 = 0, s31 = 0, s32 = 0, s3 = 0;
  for (int i = 0; i < n; i++) {
    s1 = s1 + a[i] * t1;
    t1++;
  }
  for (int i = n - 1; i >= 0; i--) {
    s1 = s1 + b[i] * t1;
    t1++;
  }
  for (int i = 0; i < n; i++) {
    s2 = s2 + b[i] * t2;
    t2++;
  }
  for (int i = n - 1; i > 0; i--) {
    s2 = s2 + a[i] * t2;
    t2++;
  }
  for (int i = 0; i < n; i += 2) {
    s31 = s31 + a[i] * t31;
    t31 += 3;
    if (i + 1 < n) s31 = s31 + a[i + 1] * t31;
    t31++;
  }
  for (int i = 0; i < n; i += 2) {
    s32 = s32 + b[i] * t32;
    t32++;
    if (i + 1 < n) s32 = s32 + b[i + 1] * t32;
    t32 += 3;
  }
  s3 = s31 + s32;
  if (s3 >= s1 && s3 >= s2)
    cout << s3;
  else if (s2 >= s1 && s2 >= s3)
    cout << s2;
  else if (s1 >= s2 && s1 >= s3)
    cout << s1;
}
