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() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<long long> a(n), b(n);
  long long sum11 = 0, sum12 = 0, sum2 = 0, sum3 = 0, counter1 = 0,
            counter2 = n * 2 - 2;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    sum11 += a[i];
    sum2 += counter1 * a[i];
    counter1++;
    if (i) {
      counter2--;
      sum3 += counter2 * a[i];
    }
  }
  for (long long i = 0; i < n; i++) {
    cin >> b[i];
    sum11 += b[i];
  }
  sum12 = sum11;
  for (long long i = n - 1; i >= 0; i--) {
    sum2 += counter1 * b[i];
    counter1++;
    counter2--;
    if (i) sum3 += counter2 * b[i];
  }
  sum12 -= a[0] + b[0];
  long long out = 0, time = 0, cur = 0;
  for (long long i = 0, j = -1; i < n; i++, j++) {
    if (i % 2 == 0) {
      out = max(out, cur + time * sum11 + sum2);
      if (i + 1 < n) {
        sum11 -= a[i] + b[i] + a[i + 1] + b[i + 1];
        sum2 -= a[i] * i;
        sum2 -= a[i + 1] * (i + 1);
        sum2 -= b[i] * (n * 2 - i - 1);
        sum2 -= b[i + 1] * (n * 2 - i - 2);
        sum2 -= sum11 * 2;
      }
      cur += a[i] * time;
      time++;
      cur += b[i] * time;
      time++;
    } else {
      out = max(out, cur + time * sum12 + sum3);
      if (i + 1 < n) {
        sum12 -= a[i] + b[i] + a[i + 1] + b[i + 1];
        sum3 -= b[i] * j;
        sum3 -= b[i + 1] * (j + 1);
        sum3 -= a[i] * ((n * 2 - 2) - j - 1);
        sum3 -= a[i + 1] * ((n * 2 - 2) - j - 2);
        sum3 -= sum12 * 2;
      }
      cur += b[i] * time;
      time++;
      cur += a[i] * time;
      time++;
    }
  }
  cout << max(cur, out) << endl;
  return 0;
}
