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::sync_with_stdio(0);
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    long long a[2][n];
    for (long long i = 0; i < n; i++) cin >> a[0][i];
    for (long long i = 0; i < n; i++) cin >> a[1][i];
    long long ans[n];
    ans[0] = 0;
    for (long long i = 0; i < n; i++) ans[0] += (a[0][i] * i);
    for (long long i = 0; i < n; i++) ans[0] += (a[1][i] * (2 * n - i - 1));
    long long suff[n];
    suff[n - 1] = a[0][n - 1] + a[1][n - 1];
    for (long long i = n - 2; i >= 0; i--)
      suff[i] = suff[i + 1] + (a[0][i] + a[1][i]);
    long long help = 0;
    ans[1] = 0;
    ans[1] += help++ * a[0][0];
    ans[1] += help++ * a[1][0];
    for (long long i = 1; i < n; i++) ans[1] += help++ * a[1][i];
    for (long long i = n - 1; i >= 1; i--) ans[1] += help++ * a[0][i];
    long long maxi = 2 * n - 1;
    long long giveit = 0;
    for (long long i = 0; i < n - 2; i += 2) {
      ans[i + 2] = ans[i];
      ans[i + 2] += suff[i + 2] * 2;
      ans[i + 2] -= maxi * a[1][i];
      ans[i + 2] += (2 * i + 1) * a[1][i];
      ans[i + 2] -= (2 * i + 1) * a[0][i + 1];
      ans[i + 2] += (2 * i + 3) * a[0][i + 1];
      ans[i + 2] -= (maxi - 1) * a[1][i + 1];
      ans[i + 2] += (2 * i + 2) * a[1][i + 1];
    }
    for (long long i = 1; i < n - 2; i += 2) {
      ans[i + 2] = ans[i];
      ans[i + 2] += suff[i + 2] * 2;
      ans[i + 2] -= maxi * a[0][i];
      ans[i + 2] += (2 * i + 1) * a[0][i];
      ans[i + 2] -= (2 * i + 1) * a[1][i + 1];
      ans[i + 2] += (2 * i + 3) * a[1][i + 1];
      ans[i + 2] -= (maxi - 1) * a[0][i + 1];
      ans[i + 2] += (2 * i + 2) * a[0][i + 1];
    }
    for (long long i = 0; i < n; i++) giveit = max(giveit, ans[i]);
    cout << giveit << endl;
  }
  return 0;
}
