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[3][300010], m, k, x, y;
long long sum1, sum2, sum3;
int main() {
  cin >> n;
  for (int i = 1; i <= 2; ++i) {
    for (int j = 1; j <= n; ++j) {
      cin >> a[i][j];
    }
  }
  m = 1;
  k = -1;
  x = 2;
  y = 1;
  int p = 1;
  while (y <= n) {
    sum1 += a[x][y] * m;
    ++m;
    if (p == 1)
      ++y;
    else {
      x += k;
      k = -k;
    }
    p = -p;
  }
  m = 1;
  for (int j = 1; j <= n; ++j) {
    sum2 += a[2][j] * m;
    ++m;
  }
  for (int j = n; j >= 2; --j) {
    sum2 += a[1][j] * m;
    ++m;
  }
  m = 1;
  for (int j = 2; j <= n; ++j) {
    sum3 += a[1][j] * m;
    ++m;
  }
  for (int j = n; j >= 1; --j) {
    sum3 += a[2][j] * m;
    ++m;
  }
  cout << max(sum1, max(sum2, sum3));
  return 0;
}
