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() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  long long a[2][n], sum = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[0][i];
  }
  for (int i = 0; i < n; i++) {
    cin >> a[1][i];
  }
  int x = 0, y = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (x == 0 && y < n - 1) {
      sum += i * a[x][y];
      y++;
    } else if (x == 0 && y == n - 1) {
      sum += i * a[x][y];
      x++;
    } else if (x == 1 && y <= n - 1 && y >= 0) {
      sum += i * a[x][y];
      y--;
    }
  }
  ans = max(ans, sum);
  sum = 0;
  x = 0, y = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (x == 0 && y == 0) {
      sum += i * a[x][y];
      x++;
    } else if (x == 1 && y < n - 1) {
      sum += i * a[x][y];
      y++;
    } else if (x == 1 && y == n - 1) {
      sum += i * a[x][y];
      x--;
    } else if (x == 0 && y >= 0) {
      sum += i * a[x][y];
      y--;
    }
  }
  ans = max(ans, sum);
  sum = 0;
  x = 0;
  y = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (y < n - 1 && (x + y) % 2) {
      sum += i * a[x][y];
      y++;
    } else {
      sum += i * a[x][y];
      x = 1 - x;
    }
  }
  ans = max(ans, sum);
  cout << ans;
  return 0;
}
