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;
const long long int maxn = 7 * 100000 + 50, inf = 1e13;
long long int a[maxn];
long long int b[maxn];
long long int a1[maxn], b1[maxn], a2[maxn], b2[maxn];
int main() {
  long long int res = -1;
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    if (i == 0) continue;
    a1[i] = a1[i - 1] + (a[i] * i);
    a2[i] = a2[i - 1] + (a[i]);
  }
  for (long long int i = 0; i < n; i++) {
    cin >> b[i];
  }
  reverse(a, a + n);
  b2[0] = b[0];
  for (long long int i = 0; i < n; i++) {
    if (i == 0) continue;
    b1[i] = b1[i - 1] + (b[i] * i);
    b2[i] = b2[i - 1] + (b[i]);
  }
  for (long long int i = 0; i < n; i++) {
    b1[i + n] = b1[n + i - 1] + (a[i] * (i + n));
    b2[i + n] = b2[n + i - 1] + (a[i]);
  }
  reverse(b, b + n);
  for (long long int i = 0; i < n; i++) {
    a1[i + n] = a1[n + i - 1] + (b[i] * (i + n));
    a2[i + n] = a2[n + i - 1] + (b[i]);
  }
  reverse(b, b + n);
  reverse(a, a + n);
  long long int o = 4, p = 0;
  res = max(res, a1[n + n - 1]);
  res = max(res, (b2[n + n - 2] + b1[n + n - 2]));
  p = 1 * b[0] + 2 * b[1] + 3 * a[1];
  for (long long int i = 2; i < n - 1; i++) {
    if (i % 2 == 0) {
      long long int x =
          a1[i + n] - a1[i - 1] + (a2[i + n] - a2[i - 1]) * (o - i) + p;
      res = max(res, x);
      p += o * a[i] + (o + 1) * b[i];
      o += 2;
    } else {
      long long int x =
          b1[i + n] - b1[i - 1] + (b2[i + n] - b2[i - 1]) * (o - i) + p;
      res = max(res, x);
      p += o * b[i] + (o + 1) * a[i];
      o += 2;
    }
  }
  if (n % 2 == 1)
    res = max(res, p + ((((n - 1) * 2)) * a[n - 1]) +
                       ((((n - 1) * 2) + 1) * b[n - 1]));
  else
    res = max(res, p + ((((n - 1) * 2)) * b[n - 1]) +
                       ((((n - 1) * 2) + 1) * a[n - 1]));
  cout << res;
  return 0;
}
