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() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  vector<int> sa(n), sb(n), ta(n), tb(n);
  sb[n - 1] = b[n - 1];
  sa[n - 1] = sb[n - 1] + a[n - 1];
  ta[n - 1] = b[n - 1];
  tb[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    sb[i] = sa[i + 1] + b[i];
    sa[i] = sb[i] + a[i];
    ta[i] = ta[i + 1] + sa[i + 1] + (2 * (n - i) - 1) * b[i];
    tb[i] = tb[i + 1] + sb[i + 1] + (2 * (n - i - 1)) * a[i + 1];
  }
  int counter = 0, curr = 0;
  int max = (ta[0] > tb[0] + sb[0]) ? ta[0] : tb[0] + sb[0];
  for (int i = 0; i < n; i += 2) {
    if (ta[i] + curr + counter * sa[i] > max)
      max = ta[i] + curr + counter * sa[i];
    curr += a[i] * counter;
    counter++;
    if (tb[i] + curr + counter * sb[i] > max)
      max = tb[i] + curr + counter * sb[i];
    curr += b[i] * counter;
    counter++;
    if (i < n - 1) {
      curr += b[i + 1] * counter + a[i + 1] * (counter + 1);
      counter += 2;
    }
  }
  cout << max;
  return 0;
}
