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;
const int oo = 0x7fffffff;
const long long OO = 0x7fffffffffffffff;
const int NX = 1 << 20;
int A[NX], B[NX], n;
long long rt1() {
  int t = 0;
  long long s = 0;
  for (int i = 0; i < n; i++) s += A[i] * long long(t++);
  for (int i = n - 1; i >= 0; i--) s += B[i] * long long(t++);
  return s;
}
long long rt2() {
  int t = 0;
  long long s = 0;
  s += A[0] * long long(t++);
  s += B[0] * long long(t++);
  for (int i = 1; i < n; i++) s += B[i] * long long(t++);
  for (int i = n - 1; i >= 1; i--) s += A[i] * long long(t++);
  return s;
}
long long rt3() {
  long long s = 0;
  int t = 0;
  for (int i = 0; i < n; i++) {
    if (i & 1) {
      s += B[i] * long long(t++);
      s += A[i] * long long(t++);
    } else {
      s += A[i] * long long(t++);
      s += B[i] * long long(t++);
    }
  }
  return s;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 0; i < n; i++) cin >> B[i];
  cout << max(max(rt2(), rt3()), rt1()) << endl;
  return 0;
}
