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;
long long n, a[300000], b[300000], acf[300000], bcf[300000], acb[300000],
    bcb[300000], acs[300000], bcs[300000];
long long acc(int r, int i, int t) {
  long long x, y;
  if (r == 0)
    x = a[i], y = b[i];
  else
    x = b[i], y = a[i];
  return t * x + (t + 1) * y;
}
long long fac(int r, int i, int t) {
  long long x, xp;
  if (r == 0) {
    if (i == 0) {
      x = acf[n - 1];
      xp = acs[n - 1];
    } else {
      x = acf[n - 1] - acf[i - 1];
      xp = acs[n - 1] - acs[i - 1];
    }
  } else {
    if (i == 0) {
      x = bcf[n - 1];
      xp = bcs[n - 1];
    } else {
      x = bcf[n - 1] - bcf[i - 1];
      xp = bcs[n - 1] - bcs[i - 1];
    }
  }
  return x - (t - i) * xp;
}
long long bac(int r, int i, int t) {
  t += n - i;
  long long x, xp;
  if (r == 0) {
    x = acb[i];
    if (i == 0)
      xp = acs[n - 1];
    else
      xp = acs[n - 1] - acs[i - 1];
  } else {
    x = bcb[i];
    if (i == 0)
      xp = bcs[n - 1];
    else
      xp = bcs[n - 1] - bcs[i - 1];
  }
  return x + t * xp;
}
long long solve(int r, int i, int t) {
  if (i == n) return 0;
  long long res = max(fac(r, i, t) + bac(1 - r, i, t),
                      acc(r, i, t) + solve(1 - r, i + 1, t + 2));
  return res;
}
int main() {
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", a + i);
  }
  for (int i = 0; i < n; i++) {
    scanf("%lld", b + i);
  }
  acs[0] = a[0];
  bcs[0] = b[0];
  for (int i = 1; i < n; i++) {
    acs[i] = a[i] + acs[i - 1];
    bcs[i] = b[i] + bcs[i - 1];
    acf[i] = i * a[i] + acf[i - 1];
    bcf[i] = i * b[i] + bcf[i - 1];
    acb[n - 1 - i] = i * a[n - 1 - i] + acb[n - i];
    bcb[n - 1 - i] = i * b[n - 1 - i] + bcb[n - i];
  }
  long long ans = solve(0, 0, 0);
  cout << ans << endl;
  return 0;
}
