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() {
  long long n;
  cin >> n;
  vector<vector<long long> > val(n + 1, vector<long long>(2, -1));
  vector<vector<long long> > sum(n + 1, vector<long long>(2, -1));
  vector<vector<long long> > csum(n + 1, vector<long long>(2, -1));
  for (long long i = 0; i < n; i++) cin >> val[i + 1][0];
  for (long long i = 0; i < n; i++) cin >> val[i + 1][1];
  for (long long i = n; i > 0; i--) {
    if (i % 2 == 0) {
      if (i + 2 <= n)
        sum[i][0] = sum[i + 2][0] + val[i][0] + val[i + 1][0] + val[i][1] +
                    val[i - 1][1];
      else {
        sum[i][0] = val[i][0] + val[i][1] + val[i - 1][1];
        if (i + 1 <= n) sum[i][0] += val[i + 1][0] + val[i + 1][1];
      }
    } else {
      if (i + 2 <= n)
        sum[i][1] = sum[i + 2][1] + val[i][1] + val[i + 1][1] + val[i][0] +
                    val[i - 1][0];
      else {
        sum[i][1] = val[i][1] + val[i][0] + val[i - 1][0];
        if (i + 1 <= n) sum[i][0] += val[i + 1][0] + val[i + 1][1];
      }
    }
  }
  for (long long i = n; i > 0; i--) {
    if (i % 2 == 0) {
      if (i + 2 <= n) {
        long long temp = 2 * (n - i + 1);
        csum[i][0] =
            csum[i + 2][0] + 2 * sum[i + 2][0] + val[i][0] + 2 * val[i + 1][0];
        csum[i][0] += temp * val[i][1] + (temp + 1) * val[i - 1][1];
      } else {
        if (i + 1 <= n)
          csum[i][0] = val[i][0] + 2 * val[i + 1][0] + 3 * val[i + 1][1] +
                       4 * val[i][1] + 5 * val[i - 1][1];
        else
          csum[i][0] = val[i][0] + 2 * val[i][1] + 3 * val[i - 1][1];
      }
    } else {
      if (i + 2 <= n) {
        long long temp = 2 * (n - i + 1);
        csum[i][1] =
            csum[i + 2][1] + 2 * sum[i + 2][0] + val[i][1] + 2 * val[i + 1][1];
        csum[i][0] += temp * val[i][0] + (temp + 1) * val[i - 1][0];
      } else {
        if (i + 1 <= n)
          csum[i][1] = val[i][1] + 2 * val[i + 1][1] + 3 * val[i + 1][0] +
                       4 * val[i][0] + 5 * val[i - 1][0];
        else
          csum[i][1] = val[i][1] + 2 * val[i][0] + 3 * val[i - 1][0];
      }
    }
  }
  long long t = 0;
  vector<long long> dp;
  long long i = 1;
  if (i + 1 <= n)
    dp.push_back(csum[i + 1][0]);
  else
    dp.push_back(val[i][1]);
  long long s = 0;
  while (i < n) {
    if (i % 2 == 1) {
      s += (t + 1) * val[i][1] + (t + 2) * val[i + 1][1];
      if (i + 2 <= n)
        dp.push_back(s + (t + 2) * sum[i + 2][1] + csum[i + 2][1]);
      else
        dp.push_back(s + (t + 3) * val[i + 1][0]);
    }
    if (i % 2 == 0) {
      s += (t + 1) * val[i][0] + (t + 2) * val[i + 1][0];
      if (i + 2 <= n)
        dp.push_back(s + (t + 2) * sum[i + 2][0] + csum[i + 2][0]);
      else
        dp.push_back(s + (t + 3) * val[i + 1][1]);
    }
    t += 2;
    i += 1;
  }
  cout << *max_element(dp.begin(), dp.end()) << endl;
}
