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;
long long int get(vector<long long int>& arr, long long int l,
                  long long int r) {
  if (l == 0)
    return arr[r];
  else
    return arr[r] - arr[l - 1];
}
long long int check1(vector<long long int>& arr, vector<long long int>& brr,
                     long long int n) {
  long long int ans = 0;
  vector<long long int> all;
  for (auto i : arr) all.push_back(i);
  for (auto i = n - 1; i >= 0; i--) all.push_back(brr[i]);
  vector<long long int> prefix(all.begin(), all.end());
  for (long long int i = 1; i < 2 * n; i++) prefix[i] += prefix[i - 1];
  long long int counter = 0;
  for (long long int i = 0; i < 2 * n; i++) {
    all[i] *= counter;
    counter++;
  }
  for (long long int i = 1; i < 2 * n; i++) all[i] += all[i - 1];
  long long int up = 1, i = 0, test = 1;
  long long int curr = 0;
  counter = 0;
  while (i < n) {
    test = (counter & 1) == 0 ? 1 : 0;
    if (up) {
      if (test) {
        long long int temp = get(all, i, (2 * n) - 1 - i);
        long long int diff = counter - i;
        temp += (diff * get(prefix, i, (2 * n) - 1 - i));
        ans = max(ans, curr + temp);
      } else {
      }
      curr += arr[i] * counter;
    } else {
      if (test) {
      } else {
      }
      curr += (brr[i] * counter);
    }
    if ((counter & 1) == 0) up = !up;
    if (!test) i++;
    counter++;
  }
  return ans;
}
long long int check2(vector<long long int>& arr, vector<long long int>& brr,
                     long long int n) {
  long long int ans = 0;
  vector<long long int> all;
  for (long long int i = 0; i < n; i++) all.push_back(brr[i]);
  for (auto i = n - 1; i >= 0; i--) all.push_back(arr[i]);
  vector<long long int> prefix(all.begin(), all.end());
  for (long long int i = 1; i < 2 * n; i++) prefix[i] += prefix[i - 1];
  long long int counter = 1;
  for (long long int i = 0; i < 2 * n; i++) {
    all[i] *= counter;
    counter++;
  }
  for (long long int i = 1; i < 2 * n; i++) all[i] += all[i - 1];
  long long int up = 1, i = 0, test = 1;
  long long int curr = 0;
  counter = 0;
  while (i < n) {
    test = (counter & 1) == 0 ? 1 : 0;
    if (up) {
      curr += arr[i] * counter;
    } else {
      if (test) {
        long long int temp = get(all, i, (2 * n) - 1 - i);
        long long int diff = counter - 1 - i;
        temp += (diff * get(prefix, i, (2 * n) - 1 - i));
        ans = max(ans, curr + temp);
      }
      curr += (brr[i] * counter);
    }
    if ((counter & 1) == 0) up = !up;
    if (!test) i++;
    counter++;
  }
  return ans;
}
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> arr(n, 0);
  vector<long long int> brr(n, 0);
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  for (long long int i = 0; i < n; i++) cin >> brr[i];
  long long int ans = check1(arr, brr, n);
  ans = max(ans, check2(arr, brr, n));
  cout << ans << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
