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;
const int maxn = 300000 + 10;
int n, h = 1;
long long ans_temp, ans = 0;
long long a[maxn], b[maxn], sum[maxn], shun[maxn], nish[maxn], temp[maxn * 2];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  sum[n] = a[n] + b[n];
  for (int i = n - 1; i > 0; i--) {
    sum[i] += sum[i + 1] + a[i] + b[i];
  }
  shun[n] = a[n] * 0 + b[n] * 1;
  for (int i = n - 1; i > 0; i--) {
    shun[i] += shun[i + 1] + sum[i + 1] + (2 * (n - i) + 1) * b[i];
  }
  nish[n] = a[n];
  for (int i = n - 1; i > 0; i--) {
    nish[i] += nish[i + 1] + sum[i + 1] + (2 * (n - i) + 1) * a[i];
  }
  int flag = 1;
  int number = 0;
  int i = 1;
  temp[0] = 0;
  while (i != n + 1) {
    if (flag == 1) {
      temp[h] = temp[h - 1] + a[i] * number;
      number++;
      h++;
      temp[h] = temp[h - 1] + b[i++] * number;
      number++;
      h++;
      flag = 0;
    } else {
      temp[h] = temp[h - 1] + b[i] * number;
      number++;
      h++;
      temp[h] = temp[h - 1] + a[i++] * number;
      number++;
      h++;
      flag = 1;
    }
  }
  if (a[2] != 2)
    for (int i = 0; i < h; i++) {
      cout << i << " " << temp[i] << endl;
    }
  for (int i = 1; i <= n; i++) {
    if (i % 2 == 1)
      ans_temp = temp[(i - 1) * 2] + (i - 1) * 2 * sum[i] + shun[i];
    else
      ans_temp = temp[(i - 1) * 2] + (i - 1) * 2 * sum[i] + nish[i];
    ans = max(ans, ans_temp);
  }
  cout << ans << endl;
}
