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, a[300000], b[300000];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);
  long long m1 = 0, m2 = 0, m3 = 0;
  long long t = 0;
  for (int i = 0; i < n; i++) {
    m1 += a[i] * t;
    t++;
  }
  for (int i = n - 1; i > -1; i--) {
    m1 += b[i] * t;
    t++;
  }
  t = 1;
  for (int i = 0; i < n; i++) {
    m2 += b[i] * t;
    t++;
  }
  for (int i = n - 1; i > 0; i--) {
    m2 += a[i] * t;
    t++;
  }
  t = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      m3 += a[i] * t;
      t++;
      m3 += b[i] * t;
      t++;
    } else {
      m3 += b[i] * t;
      t++;
      m3 += a[i] * t;
      t++;
    }
  }
  printf("%lld\n", max(m1, max(m2, m3)));
  return 0;
}
