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 Max = 300005;
long long n, total, row1[Max], row2[Max], grow[Max], u[Max], circle1[Max],
    circle2[Max];
void init_Grow() {
  int s = 0;
  for (int i = n; i >= 1; i--) {
    s += row1[i] + row2[i];
    grow[n - i + 1] = s;
  }
}
void init_U() {
  int s = 0;
  for (int i = 1; i <= n; i += 2) {
    s += row1[i] * (i * 2 - 2);
    s += row2[i] * (i * 2 - 1);
    u[i] = s;
    s += row2[i + 1] * (i * 2);
    s += row1[i + 1] * (i * 2 + 1);
    u[i + 1] = s;
  }
}
void init_Circle1() {
  int s = 0;
  for (int i = n, l = 0; i >= 1; i--, l++) {
    s += grow[l];
    s += row2[n - l] * (l + l + 1);
    circle1[i] = s;
  }
}
void init_Circle2() {
  int s = 0;
  for (int i = n, l = 0; i >= 1; i--, l++) {
    s += grow[l];
    s += row1[n - l] * (l + l + 1);
    circle2[i] = s;
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> row1[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> row2[i];
  }
  init_Grow();
  init_U();
  init_Circle1();
  init_Circle2();
  for (int i = 0; i <= n; i++) {
    if (i % 2) {
      total = max(total, u[i] + circle2[i + 1] + grow[n - i] * (i * 2));
    } else {
      total = max(total, u[i] + circle1[i + 1] + grow[n - i] * (i * 2));
    }
  }
  cout << total << endl;
  return 0;
}
