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;
long long f[300009][2], t1[300009][2], t2[300009][2], ans, m, par1[300009][2],
    par2[300009][2];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%lld", &f[i][0]);
  for (int i = 1; i <= n; ++i) scanf("%lld", &f[i][1]);
  for (int i = 1; i <= n; ++i) {
    t1[i][0] = f[i][0] * (i - 1) + t1[i - 1][0];
    par1[i][0] = (i == 1 ? 0 : f[i][0]) + par1[i - 1][0];
  }
  t1[n][1] = t1[n][0] + f[n][1] * n;
  par1[n][1] = par1[n][0] + f[n][1];
  for (int i = n - 1; i > 0; --i) {
    t1[i][1] = t1[i + 1][1] + f[i][1] * (n + n - i);
    par1[i][1] = par1[i + 1][1] + f[i][1];
  }
  for (int i = 1; i <= n; ++i) {
    t2[i][1] = t2[i - 1][1] + f[i][1] * i;
    par2[i][1] = par2[i - 1][1] + f[i][1];
  }
  t2[n][0] = f[n][0] * (n + 1) + t2[n][1];
  par2[n][0] = f[n][0] + par2[n][1];
  for (int i = n - 1; i > 1; --i) {
    t2[i][0] = t2[i + 1][0] + f[i][0] * (n + n - 1);
    par2[i][0] = par2[i + 1][0] + f[i][0];
  }
  for (int i = 1; i <= n; ++i) {
    if (i & 1) {
      long long t =
          (t1[i][1] - t1[i - 1][0]) + (par1[i][1] - par1[i - 1][0]) * (i - 1);
      ans = max(ans, t + m);
      m += f[i][0] * (i / 2 * 4);
      t = (t2[i + 1][0] - t2[i - 1][1]) +
          (par2[i + 1][0] - par2[i - 1][1]) * (i - 1);
      ans = max(ans, t + m);
      m += f[i][1] * ((i / 2 * 4) + 1);
    } else {
      long long t =
          (t2[i][0] - t2[i - 1][1]) + (par2[i][0] - par2[i - 1][0]) * (i - 2);
      ans = max(ans, t + m);
      m += f[i][1] * (i * 2 - 2);
      t = (t1[i + 1][1] - t1[i - 1][0]) +
          (par1[i + 1][1] - par1[i - 1][0]) * (i - 2);
      ans = max(ans, t + m);
      m += f[i][0] * (i * 2 - 1);
    }
  }
  printf("%d", ans);
  return 0;
}
