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 n, i, j, k, arr[2][300005], sum1[2][300005] = {0},
                                      sum2[2][300005] = {0};
long long presum1[2][300005] = {0}, presum2[2][300005] = {0};
long long cal1(long long i, long long count) {
  long long tot;
  tot = presum2[1][i - 1] - presum2[0][i - 1];
  tot -= (2 * (n - i + 1) + 1) * (sum2[1][i - 2]);
  tot += (count - 1) * (sum2[0][i] - sum2[1][i - 2]);
  return tot;
}
long long cal2(long long i, long long count) {
  long long tot;
  tot = presum1[0][i - 1] - presum1[1][i - 1];
  tot -= (2 * (n - i + 1) + 1) * (sum1[0][i - 2]);
  tot += (count - 1) * (sum1[1][i] - sum1[0][i - 2]);
  return tot;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (i = 1; i <= n; i++) cin >> arr[0][i];
  for (i = 1; i <= n; i++) cin >> arr[1][i];
  for (i = 1; i <= n; i++) sum1[0][i] = sum1[0][i - 1] + arr[0][i];
  sum1[1][n] = sum1[0][n] + arr[1][n];
  for (i = n - 1; i > 0; i--) sum1[1][i] = sum1[1][i + 1] + arr[1][i];
  for (i = 1; i <= n; i++) sum2[1][i] = sum2[1][i - 1] + arr[1][i];
  sum2[0][n] = sum2[1][n] + arr[0][n];
  for (i = n - 1; i > 0; i--) sum2[0][i] = sum2[0][i + 1] + arr[0][i];
  for (i = 1; i <= n; i++) presum2[0][i] = presum2[0][i - 1] + sum2[0][i];
  presum2[1][n] = presum2[0][n] + sum2[1][n];
  for (i = n - 1; i > 0; i--) presum2[1][i] = presum2[1][i + 1] + sum2[1][i];
  for (i = 1; i <= n; i++) presum1[1][i] = presum1[1][i - 1] + sum1[1][i];
  presum1[0][n] = presum1[1][n] + sum1[0][n];
  for (i = n - 1; i > 0; i--) presum1[0][i] = presum1[0][i + 1] + sum1[0][i];
  long long count = 0, flag = 0, maxi = 0, temp = 0, temp1 = 0;
  i = 1, j = 1;
  while (i <= n) {
    if (!flag) {
      if (i + 1 <= n) {
        temp1 = cal1(i + 1, count + 1);
        maxi = max(maxi, temp + temp1);
      }
      temp += (++count) * arr[1][i];
      if ((++i) <= n) temp += (++count) * arr[1][i];
      flag = 1;
    } else {
      if (i + 1 <= n) {
        temp1 = cal2(i + 1, count + 1);
        maxi = max(maxi, temp + temp1);
      }
      temp += (++count) * arr[0][i];
      if ((++i) <= n) temp += (++count) * arr[0][i];
      flag = 0;
    }
  }
  maxi = max(maxi, temp);
  cout << maxi;
  return 0;
}
