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>
const int mxn = 3e5 + 7;
using namespace std;
int n, a[mxn], b[mxn];
long long us[mxn][2], cir[mxn][2], sum[mxn], ans;
inline int read(int out = 0) {
  char c;
  while ((c = getchar()) < 48 || c > 57)
    ;
  while (c >= 48 && c <= 57) out = out * 10 + c - 48, c = getchar();
  return out;
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  for (int i = 1; i <= n; ++i) b[i] = read();
  for (int i = 1, las; i <= n; ++i) {
    if (i & 1) {
      us[i][0] = us[i - 1][0] + a[i] * (2 * i - 2);
      us[i][1] = us[i][0] + b[i] * (2 * i - 1);
    } else {
      us[i][1] = us[i - 1][1] + b[i] * (2 * i - 2);
      us[i][0] = us[i][1] + a[i] * (2 * i - 1);
    }
    cir[i][0] += a[i] * (i - 1) + b[i] * (n + n - i);
    cir[i + 1][0] += cir[i][0];
    cir[i][1] += b[i] * i + a[i] * (n + n - i + 1), cir[i + 1][1] += cir[i][1];
    sum[i] = sum[i - 1] + a[i] + b[i];
  }
  for (int i = 1; i <= n + 1; ++i) {
    if (i & 1)
      ans = max(ans, us[i - 1][0] + cir[n][0] - cir[i - 1][0] +
                         (sum[n] - sum[i - 1]) * (i - 1));
    else
      ans = max(ans, us[i - 1][1] + cir[n][1] - cir[i - 1][1] +
                         (sum[n] - sum[i - 1]) * (i - 2));
  }
  ans = max(ans, cir[n][0]);
  ans = max(ans, cir[n][1]);
  cout << ans;
  return 0;
}
