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() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> first(n);
  vector<long long> second(n);
  for (long long i = 0; i < n; i++) cin >> first[i];
  for (long long i = 0; i < n; i++) cin >> second[i];
  long long sum1 = 0, sum2 = 0, sum3 = 0;
  for (long long i = 0; i < n; i++) {
    sum1 += i * first[i];
  }
  long long kaj = n;
  for (long long i = n; i >= 1; i--) {
    sum1 += kaj * second[i - 1];
    kaj++;
  }
  for (long long i = 1; i <= n; i++) {
    sum2 += i * second[i - 1];
  }
  long long j = n - 1;
  for (long long i = n + 1; i < 2 * n; i++) {
    sum2 += i * first[j];
    j--;
  }
  long long maxa = (2 * n - 1);
  j = 1;
  while (j <= maxa) {
    sum3 += j * (second[j / 2]);
    if (j % 2 != 0)
      j++;
    else
      j += 3;
  }
  if (n >= 2) {
    j = 3;
    while (j <= 2 * n - 1) {
      sum3 += j * first[j / 2];
      if (j % 2 != 0)
        ++j;
      else
        j += 3;
    }
  }
  long long max1 = max(sum1, sum2);
  cout << max(sum3, max1);
}
